Is there a way to only redirect the homepage and not subpages to a mobile site? I have a small mobile site so many of my pages do not have mobile equivalents. I've been able to setup the module so it lists all the directories without mobile equivalents as exceptions not to redirect, but I figured settting it up so that only the homepage is redirected would be easier.

I saw that I can check off "Do only redirect from the following pages", but am not sure what to put for the homepage. Is it ? Also, when I checked that off and added a few directories to redirect, it was still redirecting pages not in the list.

Comments

larryhackman’s picture

I too have the same exact problem. Using / as the only redirect page seemed not to do the trick.

Specifically, I am not redirecting to a subdomain, only to a new page, so for example www.example.com/mobile instead of mobile.example.com. But mobile tools will send anything to www.example.com/mobile/whatever and I get nasty 404 pages. But all I want is a different homepage.

Would be interested in a solution...

larryhackman’s picture

Found a solution! jwbuzz found a typo in mobile_tools.module and replaced one line (434, though it was different in Coda...) with this:

if (isset($_GET['q']) && variable_get('mobile_tools_redirect_exceptions_type', 0) == 'only-redirect') {

This totally did the trick for me.

You can see his work here.

mbiddlecombe’s picture

do you still have / in the exceptions box? can't seem to get this fix to work for me.

organicwire’s picture

Status:Needs review» Active

I also encountered this bug. What I need is that a redirection is done only when the browser hits the frontpage.

I tried to solve this by configuring mobile tools like this:

--- Redirection options -------
[x] Enable automatic redirection of the mobile user

exception type:
( ) Do not redirect from the following pages
(o) Do only redirect from the following pages

redirection exceptions:
  homepage                    (homepage is configured as my front page)
  <front>
  /

As I understand the mobile_tools code, these settings are ignored if there's no q parameter in $_GET. In other words, the abovementioned settings are not taking into account if the browser hits the front page.

I was able to fix this: a condition in mobile_tools_device_redirect() needs to be removed: if (isset($_GET['q'] && ...).

Please review my fix, following in a minute or so.

organicwire’s picture

Version:6.x-1.x-dev» 6.x-2.x-dev
Category:support» bug
StatusFileSize
new735 bytes
organicwire’s picture

Status:Active» Needs review
Jt Hollister’s picture

Status:Active» Needs review

Hey um, doesn't this need to be applied to the hosted module? Because to me it seems like that's a pretty critical bug, I mean the single most important purpose of a tool like this would be to redirect the home page and you can't. I am pretty surprised it's not fixed by now :/

I do appreciate the patch though, worked like a charm. Why not just commit?

also verbiage suggestion:
"Give the paths to pages that should not be redirected. Put each path on a seperate line. The '*' character is a wildcard."
"Pages that should/should not be redirected. Place each path on a seperate line. '*' is a wildcard and '<front>' can be used for the home page."

hwasem’s picture

I downloaded the module yesterday and came across the problem with trying to only redirect my homepage. The patch in #5 worked for me, as well.

Great module and I look forward to hearing about the updated release so I can deploy on my production site!

Thanks!

todea’s picture

I also need to be able to redirect my homepage only. The patch in #5 worked for me. Not sure if there was a problem with my setup but I had to manually apply the patch.

yashadev’s picture

Status:Needs review» Reviewed & tested by the community
Devin Carlson’s picture

Assigned:Unassigned» Devin Carlson
Status:Reviewed & tested by the community» Needs review
StatusFileSize
new3.03 KB

An updated patch against 6.x-2.x for testing.

Devin Carlson’s picture

memcinto’s picture

This patch (the one in #11) made my site whitescreen (thankfully a test site). I used drush to clear cache and run cron, still whitescreening. I tried to disable the module using drush, drush threw up:

drush dis mobile_tools
The following extensions will be disabled: mobile_tools, mobile_tools_roles
Do you really want to continue? (y/n): y
WD file system: The directory sites/ahsl.arizona.edu/files/images is not writable, because it [error]
does not have the correct permissions set.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /htdocs/drupal/drupal-6.19/sites/all/modules/ctools/includes/export-ui.inc on line 270

Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in
/htdocs/drupal/drupal-6.19/sites/all/modules/ctools/includes/export-ui.inc, line 270

The site was majorly messed up with out-of-memory errors. Most admin pages would whitescreen. I couldn't get to the modules page to disable things and I couldn't use drush to disable things. I removed the mobile tools module at the file layer and that didn't fix it. I put an unpatched version of mobile tools in place and that didn't fix it. It looked like from what I *could* see, as though every module on the site was enabled - no wonder the poor thing was out of memory! I could not fix it, and finally overwrote the database with a dump from the production site - that fixed it, of course.

I then applied the patch in #5 and that temporarily fixed the homepage redirecting problem - until it stopped fixing it.

Devin Carlson’s picture

organicwire’s picture

Are there any news about the patches in #5 and #11? Did they go into the module?

Cheers

hwasem’s picture

Patch #5 worked for me, as well. I had to reapply that patch with the upgrade to the latest Mobile Tools 6.x-2.7 in order to have redirection work. Although the lines of code to patch changed from 267 to 251.

organicwire’s picture

Status:Needs review» Reviewed & tested by the community

Patch #5 seems to be solidly tested. Let's take it into the module.

Devin Carlson’s picture

Status:Reviewed & tested by the community» Fixed

Committed #5 to 6.x-2.x.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.