Forum Moderators: phranque
RewriteCond %{REMOTE_ADDR} 123.123.123.123
RewriteRule .* http://www.example.com/ [R=301,L]
Now if someone with ip: 123.123.123.123 connects, he wil be redirected to http://www.example.com
This works!
But if I want to redirect 123.123.123.123 only when he is using internet-explorer and leave him non-redirected when he is using for example firefox, how can I combine this with a "Browsermatch"?
Any hints please?
[edited by: Cees at 12:48 pm (utc) on Jan. 22, 2008]
Note that further exclusions are required, since otherwise *all* URLs would be redirected, including those for images, CSS, and JavaScript files.
That is not likely to be what you want. You will probably need to exclude requests that are not for "pages", and also exclude the "real" URL-paths to your directory index files, as shown (this code supports .htm, .hmtl, .shtm, .shtml, .php, and .php1 through .php9).
RewriteCond $1 \.(s?html?¦php[1-9]?)$
RewriteCond $1 !/?index\.(s?html?¦php[1-9]?)$
RewriteCond %{REMOTE_ADDR} ^123\.123\.123\.123$
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/[0-9.]+\ \([^)]+\)\ Gecko/20[0-9]{6}\ Firefox/[0-9.]+
RewriteRule (.*) http://www.example.com/ [R=301,L]
Jim