Leading Slash in URL

New to mod_rewrite? This is a good place to start.

Leading Slash in URL

Postby sharingsunshine » Fri Dec 28, 2007 5:38 am

I have noticed in my logs that some users are inserting a leading slash before the http://abc.com urls in my site. In this manner, /http://abc.com

These are legitimate and important links except for the leading slash.

Here is the regex I came up with but it doesn't seem to work I am guessing because it is at the beginning of the url.

RedirectMatch 301 /http://(.*)$ http://$1

Please help me fix this problem.

Thanks,

Randal
sharingsunshine
 
Posts: 54
Joined: Tue Dec 19, 2006 5:32 am

Postby richardk » Fri Dec 28, 2007 3:09 pm

Do you get a forbidden error? If you do, you will probably need access to the httpd.conf file to set up a redirect.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sharingsunshine » Fri Dec 28, 2007 4:41 pm

Actually, that error is not in my current error log so I am not able to get the details right now.

Another error, that I thought would follow the same reasoning because it was at the start of the url too, is having a leading comma. Here are the details on that error.

No, it is just showing a 404 error. Here is the entry in the access log. By the way, this is the googlebot.

66.249.67.41 - - [28/Dec/2007:03:09:50 -0700] "GET /, HTTP/1.1" 404 4548 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Thanks,

Randal
sharingsunshine
 
Posts: 54
Joined: Tue Dec 19, 2006 5:32 am

Postby sharingsunshine » Fri Dec 28, 2007 8:08 pm

Here is the entry and it is just a 404 too:

64.124.148.26 - - [24/Dec/2007:19:34:59 -0700] "GET /http:/www.abc.com/register.php HTTP/1.1" 404 18243 "-" "Mozilla/5.0 (compatible; FatBot 2.0; http://www.thefind.com/main/CrawlerFAQs.fhtml)"

notice the / in front of the http:// that is what I want to get rid of.

Thanks,

Randal
sharingsunshine
 
Posts: 54
Joined: Tue Dec 19, 2006 5:32 am

Postby richardk » Sat Dec 29, 2007 1:50 pm

What happens when you type a /http://... URL in?

You can try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(http://.+)$ $1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sharingsunshine » Sat Dec 29, 2007 8:53 pm

When I type in a url with /http://www.abc.com

Firefox gives this answer:

Firefox can't find the file at /http:/abc.com/index.html

Notice it has taken one of the forward slashes after the colon. Although, the browser bar is still showing it in this manner:

/http://www.abc.com/index.html

If I remove the rewrite rule altogether I still get the same message from Firefox.

I appreciate your help.

Randal
sharingsunshine
 
Posts: 54
Joined: Tue Dec 19, 2006 5:32 am

Postby richardk » Mon Dec 31, 2007 11:46 am

For your-domain.tld/http://another-domain.tld/?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 5 guests