0

I've pored through other questions to find a solution, and the closest I've come is Zerobinary99's question here: How do regular expressions work in htaccess to redirect an IP range

However, I'm not having luck. I can redirect a user from an IP range to another site completely, but I can't redirect a user to another page on my site. Here's what I have (this is a Wordpress site, btw - don't know if that matters):

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} ^108\.196\.108\.
RewriteCond %{REQUEST_URI} /devops/$
RewriteRule .* /dev-ops/ [R=301,L]

However I still get mysite.com/devops when I navigate to that URL from the specified IP range, instead of being redirected to mysite.com/dev-ops. What am I doing wrong?

0

Got it - I ended up with the following (including multiple ip ranges using [OR]) to redirect visitors in the specified ranges from the devops url to dev-ops:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} ^108\.196\.108\. [OR]
RewriteCond %{REMOTE_ADDR} ^108\.196\.110\. [OR]
RewriteRule devops/ dev-ops/ [R=301,L]

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.