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.

1
  • 2
    Please divulge more information on how you are currently doing the redirect.
    – Tim
    Jan 20, 2012 at 20:04

2 Answers 2

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.

1
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"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .