Forum Moderators: phranque
The problem is I have a hosting account at hostgator which runs an earlier version of apache. I need to redirect anyone who isnt using firefox, internet explorer or opera as a browser to another file. I made the following:
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5.0.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/4\.[0-9]+\ \(compatible;\ MSIE\ [0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Opera/[0-9.]+
RewriteRule ^test/index.html [mysite.com...] [R=301,L]
The code seems to work fine on the hostgator hosting account. The problem is on my sever which runs apache 2.0+. For some odd reason the code doesnt work at all anymore, this problem has happened in the past as well when using other codes. I asked some people but all they could tell me was that the L flag may be causing problems, I tried removing it but still got the same problem.
Hope someone can help :)
have you removed the RewriteCond statements to see if it works without any conditions?
If not already configured, you will need:
In httpd.conf :
Allow Override All
and in .htaccess, preceding any other mod_rewrite directives :
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine on
Always completely flush your browser cache (or "Temporary Internet Files" in Internet Explorer) before testing any new code, otherwise, you are likely looking at the results of a cached server response.
If this does not help, please post specifics of how "it doesn't work" such as:
Jim
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5.0.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/4\.[0-9]+\ \(compatible;\ MSIE\ [0-9.]+
RewriteCond %{HTTP_USER_AGENT} !^Opera/[0-9.]+
RewriteRule ^test/index.html http://example.com/test/index.php [R=301,L]
[edited by: jdMorgan at 1:50 am (utc) on Feb. 16, 2008]
[edit reason] example.com [/edit]
Thanks for all the replies. I tried what was said but it still doesnt seem to make a difference.
Whats wrong:
- It wont redirect someone when they arent using the required browsers
- I tested it by removing the firefox conditional (RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5.0.*$ [NC]) and going to the website with firefox, doesnt redirect.
- The results differ because the code works fine on my hostgator hosting account.
Thanks