I recently setup a 301 rewrite rule on my website which redirects a specific IP to a seperate site.

Now, I do not want people being able to directly access by going to the domain.

So this should work right?

In Main Site .htaccess

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-For} ^($
RewriteRule (.*) http://lol.corihaws.co.uk [R=301,L]

RewriteCond %{HTTP_HOST} ^corihaws.co.uk
RewriteRule (.*) http://www.corihaws.co.uk/$1 [R=301,L]

In Redirect Sites .htaccess

RewriteEngine On
RewriteCond %{HTTP_REFERER} !corihaws.co.uk$ [NC]
RewriteRule (.*) http://www.corihaws.co.uk [R=301,L]

I keep getting a redirect loop preventing the page from loading. I am using Cloudflare which is a reverse proxy service so this is why I am using X-Forward-For instead of REMOTE_ADDR.
Everything loads as it should without the Redirects .htaccess. Can anyone give me some ideas.

Read more here: Redirect Loop issues


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: