Post by dom44 » Tue Oct 04, 2011 11:13 am

Hi,

I'm am trying to block a group of IP addresses from my store but I don't want to visitor to see a "forbidden page" but rather a "contact us" page.

I did some googling and got some help from this forum and came up with this to put in my .htaccess file:

Code: Select all

Options +FollowSymlinks 
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} ^(123\.123\.123\.123)$
RewriteRule ^/* contactus.html [R=301,L]
Right now I am testing it with my own IP address and since contactus.html is in the same directory it is also getting blocked and it is causing an infinite loop.

Besides setting the redirect to another website, is there anyway to solve this problem?

Any help would be greatly appreciated.

Thank you

New member

Posts

Joined
Thu Jul 16, 2009 6:54 am

Post by uksitebuilder » Tue Oct 04, 2011 3:15 pm

the following should work

Code: Select all

RewriteCond %{REMOTE_HOST} ^123\.45\.67\.89
RewriteCond %{REQUEST_URI} !/contactus\.html$
RewriteRule \.html$ /contactus.html [R=302,L]
The 2nd line excludes that page so in theory should stop the redirect loop you were getting

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by dom44 » Thu Oct 06, 2011 12:45 pm

Thanks Simon for all the help.

For some reason I could not get your exact code to work, but I blended it with the old code I had and got it to work.

For those of you'll who have the same problem, this is the code that worked for me:

Code: Select all

Options +FollowSymlinks 
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} ^(123\.45\.67\.89)$	
RewriteCond %{REQUEST_URI} !/contactus\.html
RewriteRule .* /contactus.html 

New member

Posts

Joined
Thu Jul 16, 2009 6:54 am
Who is online

Users browsing this forum: No registered users and 72 guests