Please help I've tried hard but it just doesn't work.
What i'm trying to accomplish is simply redirect all users within our company network (all with the same external ip address, let's say 192.168.0.1) to htp://start.example.com/page_2 when they visit htp://start.example.com/page_1. All other ip addresses should be just fine visiting htp://start.example.com/page_1.
Ive tried these 2 rules:
1:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^192\.168\.0\.1$
Redirect 301 /page_1 http://start.example.com/page_2
In this case the redirect only works when the ip check is disabled.
2:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} ^192\.168\.0\.1$
RewriteCond %{REQUEST_URI} !^page_2$
RewriteRule .* http://start.example.com/page_2 [R=301,L,NC]
In this case the redirect only works when the path check is disabled.
What is wrong?
Oké, found the solution, Somehow the position of the redirect just didn't work, i moved it to the top of the document and now it works with the following syntax. In the example I've added an extra IP check and a User agent "Windows" check.
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} ^192\.168\.0\.1$ [NC,OR]
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.1$ [NC]
RewriteCond %{HTTP_USER_AGENT} Windows
RewriteRule page_1$ http://start.example.com/page_2 [R,L,NC]