Forum Moderators: phranque

Message Too Old, No Replies

ErrorDocument / RewriteRule and double slash after .com

Problem witch apache rewrite rules for double slash

         

leandre

1:46 pm on Jun 6, 2008 (gmt 0)

10+ Year Member



Hello,

Sorry my english is poor :(

Im use apache 2.2.8-r3

I have problem witch double // in my url, and i find a solution but ErrorDocument is doesnt work for double slash after .com

Ex : www.example.com//toto = 404
But i have this message :
Not Found

The requested URL / was not found on this server.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Or my page is 404 but im not view a good page witch ErrorDocument :(

but my config work evrywhere :

Ex : www.example.com/titi//lala = 404 and i view a good page 404

This is my configuration :

ErrorDocument 404 /404

#Rewrite rule
Options +FollowSymLinks
RewriteEngine On

#Remove double slash after .com
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . http://www.example.com%1/%2 [R=404,L]

#remove multiple slashes before URL-path
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://www.example.com/%1 [R=404,L]

If you have any idea about to solve my problem, it would be very nice from your part.

PS : I know, 301 and no problem, but im prefer 404

jdMorgan

3:37 pm on Jun 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the name of your custom 404 ErrorDocument? Is it a .html file, a .php file, or other? If you do not have such a page on your site, the result will be the 500-Server Error you mention.

Your two rules are designed to generate 404 errors, and are not consistent with the comments that precede them. A better approach is to generate a 301 redirect to "correct" the double-slashed URLs:


# Redirect to remove double slash within URL-path
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . http://www.example.com%1/%2 [R=301,L]
#
# Redirect to remove multiple slashes before URL-path
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://www.example.com/%1 [R=301,L]

Jim