homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

This redirect doesn't work ?

 7:48 pm on Apr 4, 2011 (gmt 0)

Can anyone see any reason why the redirects below wouldn't work please ?

RewriteEngine on
Options +FollowSymlinks

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^120\.50\.18\. [OR]
RewriteCond %{REMOTE_ADDR} ^121\.96\.171\. [OR]
RewriteCond %{REMOTE_ADDR} ^217\.196\.17\. [OR]
RewriteCond %{REMOTE_ADDR} ^78\.147\.174\.
RewriteRule /403.php [L,R=301]



 7:53 pm on Apr 4, 2011 (gmt 0)

I've tested it with my IP address, but it still never takes me to the 403.php page ? ? I'm almost 100% sure I've followed the instructions in these threads.

Any help much appreciated.



 9:34 pm on Apr 4, 2011 (gmt 0)

Your RewriteRule is looking for a URL request like
www.example.com/<anything-or-nothing>/403.php and fails to specify a new URL to redirect to.

Even if your code had worked, it would have sent a 301 response back, and not a 403 response.

Omitting the IP checks (add those back in yourself) the rule should be something like:

RewriteCond %{REQUEST_URI} !/403\.php
RewriteRule .* - [F]

ErrorDocument 403 /403.php

 9:20 am on Apr 5, 2011 (gmt 0)

Thanks for that, it's appreciated. The request is just to affect unwanted IP's. I still want any good IP's that have just typed in the wrong address to get a 404 and then redirect to the home page after a short message to say that they will be redirected to the home page in a few seconds. Does what you suggest affect that at all please?


 7:29 am on Apr 7, 2011 (gmt 0)

Anyone ?


 7:09 pm on Apr 7, 2011 (gmt 0)

The 404 ErrorDocument should be served at the originally requested URL, should return a 404 HTTP status, a plain text human readable error message, and optionally some clickable links to related content.

It should not "redirect" anywhere, especially not to the home page.


 8:06 pm on Apr 7, 2011 (gmt 0)

Thanks for the info. I'm getting a little confused as I feel a little out of my depth here ;-( I know on one of my sites, if a user types a wrong url into the address bar, it takes them to an error page, then after 5 seconds, it refreshes them to the home page.


 8:15 pm on Apr 7, 2011 (gmt 0)

Ah, the refresh is likely using javascript or the meta refresh element. That's generally not a good idea. It can confuse humans a searchengines alike.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved