0

I'd like to redirect users to the mobile version of my website using apache based on UserAgent

However if a user chooses to view the full version of the site by clicking on a URL that was the ?ver=full URL parameter, I'd like to stop redirecting them. How can I accomplish this?

The pages are all .html so I don't have the benefit of using php or a similar language.

ckliborn
  • 2,778
  • 4
  • 25
  • 37

2 Answers2

2

I'm going to go out on a limb and assume that you're redirecting them with mod_rewrite based on their user agent string.

If that's the case, then something like this, added to the condition list:

RewriteCond %{QUERY_STRING} !ver=full [NC]

But, keep in mind that they'd need to keep this parameter in every request they send, including all other links they follow (potentially, depending on your current configuration) requests for static content like images and CSS.. you might want to consider setting a cookie instead of using a URL parameter (or trigger based on either, and set the cookie when the parameter is seen). We can do the cookie through some far more complex mod_rewrite stuff, too - I can assist with that config if that's the direction you'd like to go.

Provide your current configuration and we can talk specifics.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • I'd like to use a cookie with mod_rewrite. I don't have a current config. I am working on one in this Question http://serverfault.com/questions/352879/how-can-i-use-apache-to-redirect-users-based-on-user-agent-and-using-mod-rewrit – ckliborn Jan 23 '12 at 21:52
0

You should investigate Apache's mod_rewrite

Example 4 has a rule for redirecting based on user agent. What you need to add is a condition where this rule is run only if the URL does not contain "?ver=full"

sreimer
  • 2,218
  • 15
  • 17