I have a site that is heavily dependant on Flash (I know, I know … ). For this reason I have a redirect using .htaccess on my webhost’s Linux server. It works extremely well.
However, I am noticing that people are accessing my mobile site, via desktop browsers, which is not ideal. I would very much like to be able to do the reverse redirect (!) using .htaccess but it is waaaay beyond my ability (despite many attempts).
It occurred, having just put a simple redirect into the child sites that are referenced via iFrames to avoid them being orphaned (thanks Walter!) that I might do the same thing for my Mobile site. I fear looping though, which obviously, I might never even know is happening.
In resume, I want to redirect my Mobile site, to my Desktop site, for all the browsers that are NOT included in the .htaccess redirect that is already in place.
I haven’t tested that, but it should return true if the current browser is not one of those options. Do that in a separate rule, under the first one, so make it look like this, maybe:
No, the first condition just checks that there is something in the request besides /, and then passes along to the next one. The other two should be inverse of one another. One should select all mobile browsers, the other should select all non-mobile browsers. Try adding [R,L] at the end of both the index_m.html and index.html lines. That should make it completely unambiguous that if one matches, the redirect should happen (R for Redirect) and no more rules should be tried (L for Last).
Walter
On Mar 21, 2012, at 3:07 PM, grantsymon wrote:
Thanks Walter.
No go I’m afraid.
Is the first condition (RewriteCond %{REQUEST_URI} ^/$) perhaps negating the ! one?
Is there something that can be added as a redirect on the mobile site, using the same criteria, that wouldn’t result in a loop from the htaccess file … or is this getting into too dangerous territory?
You should be able to do this entirely within the htaccess file. The issue is likely that the regular expression isn’t matching for some reason. Try removing the parentheses, see if that’s tripping it up. The syntax for mod_rewrite is different than regular expressions in other environments, always have to fiddle to get these to work properly.
Walter
On Mar 21, 2012, at 3:22 PM, grantsymon wrote:
No luck here either Walter.
Is there something that can be added as a redirect on the mobile site, using the same criteria, that wouldn’t result in a loop from the htaccess file … or is this getting into too dangerous territory?
Reviving this old thread. I’m having a similar problem with search engines picking up the mobile site and showing it to desktop users. I understand from reading this that a redirect can be created using .htaccess but I’m not sure this was ever resolved. Can somebody tell me what the .htaccess file needs to say?
By the way I use the mobile redirect action to repoint mobile users to the mobile site. Might there perchance be a desktop redirect action? Just wondering…
I’m not sure how that would work. I suppose an .htaccess file (which would have access to the User-Agent string of the browser) could do something based on the name of the browser or some other thing, but those kinds of actions tend to be really harsh, and can easily get out of date as browsers update and change.
The modern way around this is to build one site that works for all clients, using CSS and viewport size queries to rescale the interface to suit the browser.
Freeway has supported this in one way or another for several years. It doesn’t do much for your mobile site as it stands, but it gives you an opportunity to redesign and improve.
Walter
On Mar 19, 2019, at 11:54 PM, Richard Cacciato email@hidden wrote:
Reviving this old thread. I’m having a similar problem with search engines picking up the mobile site and showing it to desktop users. I understand from reading this that a redirect can be created using .htaccess but I’m not sure this was ever resolved. Can somebody tell me what the .htaccess file needs to say?
By the way I use the mobile redirect action to repoint mobile users to the mobile site. Might there perchance be a desktop redirect action? Just wondering…