Hello,
This is my first post in SitePoint. I need help with something. Please help. I’m a amateur regarding htaccess,
so please bear with me as I try to explain what I need done.
I want to redirect all versions of IE browsers from one page to another internal page (not 301 redirect),
and also redirect all Spanish and German traffic/users to the same respective pages.
I have 4 specific pages that I need to do this on.
I did get some help over at webmasterworld.com/apache/ , but the problem is that the main guy running
that forum has a hectic time in life and can’t support the forum as much any more. So, here’s what I got:
# 302 Redirect MSIE requests for all .htm pages except for NEW.htm itself to NEW.htm
RewriteCond %{REQUEST_URI} !^/NEW\\.htm$
RewriteCond %{HTTP_USER_AGENT} ^([^\\ ]+\\ )+MSIE\\ [0-9]+\\.
RewriteRule \\.htm$ http://www.example.com/NEW.htm [R=302,L]
#
# 302 Redirect requests having German or Spanish as the FIRST language
# preference for any of these four specific pages to NEW.htm
RewriteCond %{HTTP:Accept-Language} ^(de|es)([,;\\-].+)?$ [NC]
RewriteRule ^(PAGE1|PAGE2|PAGE3|PAGE4)\\.htm$ http://www.example.com/NEW.htm [R=302,L]
Regarding the first code - Redirecting MSIE users:
The first part of this code redirect all MSIE users that arrive in this directory to NEW.htm
The problem here is that I have a lot of other pages in the directory, and I don’t want all these pages to be effected.
Only 4 of them. And these 4 should redirect (ONLY for MSIE users) to a similar page but different.
I want it done like this:
page1.htm to be redirected to page1.new.htm
page2.htm to be redirected to page2.new.htm
page3.htm to be redirected to page3.new.htm
page4.htm to be redirected to page4.new.htm
Regarding the second code - Redirecting ES and DE users:
The second part of this code redirect all ES and DE users that arrive at page1.htm, page2.htm, page3.htm and page4.htm in this directory to NEW.htm
But I want them to be redirected like this:
page1.htm to be redirected to page1.new.htm
page2.htm to be redirected to page2.new.htm
page3.htm to be redirected to page3.new.htm
page4.htm to be redirected to page4.new.htm
…
I was told that the command “RewriteCond” only applies to the next line, so I asked:
“Because the RewriteCond only applies to the first RewriteRule should I put in 4 RewriteCond lines,
and get rid of the {REQUEST_URI} line at the top since not all are going to get redirected to the same page?”
RewriteCond %{HTTP_USER_AGENT} ^([^\\ ]+\\ )+MSIE\\ [0-9]+\\.
RewriteRule ^(PAGE1)\\.htm$ http://www.example.com/page1.new.htm [R=302,L]
RewriteCond %{HTTP_USER_AGENT} ^([^\\ ]+\\ )+MSIE\\ [0-9]+\\.
RewriteRule ^(PAGE2)\\.htm$ http://www.example.com/page2.new.htm [R=302,L]
RewriteCond %{HTTP_USER_AGENT} ^([^\\ ]+\\ )+MSIE\\ [0-9]+\\.
RewriteRule ^(PAGE3)\\.htm$ http://www.example.com/page3.new.htm [R=302,L]
RewriteCond %{HTTP_USER_AGENT} ^([^\\ ]+\\ )+MSIE\\ [0-9]+\\.
RewriteRule ^(PAGE4)\\.htm$ http://www.example.com/page4.new.htm [R=302,L]
… but I did not get any clear answer to this.
And I also asked regarding the second code:
“And the same goes for the {HTTP:Accept-Language} code, redirecting Spanish and German browsers as follows:”
RewriteCond %{HTTP:Accept-Language} ^(de|es)([,;\\-].+)?$ [NC]
RewriteRule ^(PAGE1)\\.htm$ http://www.example.com/page1.new.htm [R=302,L]
RewriteCond %{HTTP:Accept-Language} ^(de|es)([,;\\-].+)?$ [NC]
RewriteRule ^(PAGE2)\\.htm$ http://www.example.com/page2.new.htm [R=302,L]
RewriteCond %{HTTP:Accept-Language} ^(de|es)([,;\\-].+)?$ [NC]
RewriteRule ^(PAGE3)\\.htm$ http://www.example.com/page3.new.htm [R=302,L]
RewriteCond %{HTTP:Accept-Language} ^(de|es)([,;\\-].+)?$ [NC]
RewriteRule ^(PAGE4)\\.htm$ http://www.example.com/page4.new.htm [R=302,L]
… but I did not get any clear answer to this either.
Can someone in here please help?