Click here to get back home

Redirecting double-slash ("//") URLs to single-slash ("/") URLs

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Redirecting double-slash ("//") URLs to single-slash ("/") URLs Guy Macon 07-03-2008
Get Chitika Premium
Posted by Guy Macon on July 3, 2008, 6:42 pm
Please log in for more thread options



As a personal learning experience with limited practical use,
I have been doing some experiments with using .htaccess to
redirect mis-typed URLs to a preferred canonical form. I have
set up a test page at [ http://www.guymacon.org/test.html ]
to show the results of my testing.

Most of the URLs redirect as I want them to do, but the three
URLS (with "//" instead of "/") in bold do not redirect.

I have searched the web and have not found a single website
that redirects *all* "//" URLs to "/" URLs.

Given the rarity of this error, a solution that causes a 404
error rather than a 301 redirect would be fine with me, but I
haven't seen any websites that manage that one either.

Any suggestions for things to try would be most welcome.
Thanks!

[ http://www.guymacon.org/test.html ]

--
Guy Macon
<http://www.GuyMacon.com/>


Posted by Steve on July 3, 2008, 9:13 pm
Please log in for more thread options
Guy Macon wrote:
> As a personal learning experience with limited practical use,
> I have been doing some experiments with using .htaccess to
> redirect mis-typed URLs to a preferred canonical form. I have
> set up a test page at [ http://www.guymacon.org/test.html ]
> to show the results of my testing.
>
> Most of the URLs redirect as I want them to do, but the three
> URLS (with "//" instead of "/") in bold do not redirect.
>
> I have searched the web and have not found a single website
> that redirects *all* "//" URLs to "/" URLs.
>
> Given the rarity of this error, a solution that causes a 404
> error rather than a 301 redirect would be fine with me, but I
> haven't seen any websites that manage that one either.
>
> Any suggestions for things to try would be most welcome.
> Thanks!
>
> [ http://www.guymacon.org/test.html ]
>

Haven't tested but this guy's approach looks good on paper if you have
access to PHP (probably easy enough to replicate in any server-side
language):

http://groups.google.com/group/alt.internet.search-engines/msg/9a0f7baad24c74dc

Dunno. It's a nearly 3-year old thread you were actually involved in,
so perhaps it doesn't work.

Posted by Steve on July 3, 2008, 9:14 pm
Please log in for more thread options
Steve wrote:

> Dunno. It's a nearly 3-year old thread you were actually involved in,
> so perhaps it doesn't work.

... and by that, I mean perhaps you already tried it. Just re-read and
that sentence came off as an insult, which wasn't my intent.

Posted by Guy Macon on July 4, 2008, 5:23 am
Please log in for more thread options



Steve wrote:

>Haven't tested but this guy's approach looks good on paper if you have
>access to PHP (probably easy enough to replicate in any server-side
>language):
>
>http://groups.google.com/group/alt.internet.search-engines/msg/9a0f7baad24c74dc

Thanks!

I put it in my .htaccess -- you can see the results by clicking on
the three bold URLs at [ http://www.guymacon.org/test.html ].


--
Guy Macon
<http://www.GuyMacon.com/>


Posted by Guy Macon on July 6, 2008, 4:38 am
Please log in for more thread options



Guy Macon wrote:
>
>Steve wrote:
>
>>Haven't tested but this guy's approach looks good on paper if you have
>>access to PHP (probably easy enough to replicate in any server-side
>>language):
>>
>>http://groups.google.com/group/alt.internet.search-engines/msg/9a0f7baad24c74dc
>
>Thanks!
>
>I put it in my .htaccess -- you can see the results by clicking on
>the three bold URLs at [ http://www.guymacon.org/test.html ].

I am now removing it again. The result was, as I expected, that
It did not handle the test cases in bold at
[ http://www.guymacon.org/test.html ].
As far as I can tell, no website anywhere is able to handle all
of those test cases using .htaccess -- I am convinced that Apache
converts some "//"s to "/"s prior to feeding user request to
mod_rewrite.


--
Guy Macon
<http://www.GuyMacon.com/>


Similar ThreadsPosted
Commas in URLs? August 16, 2005, 2:28 pm
Ampersands in urls May 21, 2005, 11:03 am
frames and URLs May 27, 2008, 9:33 am
Is it good to use absolute URLs? November 4, 2004, 11:42 am
RFC3986, backslash in URI/URLs June 10, 2006, 7:25 am
Default dir for file urls. February 27, 2007, 8:24 pm
URLs of recommended sitemaps? February 14, 2008, 5:25 pm
Long URLs giving GET problems January 28, 2005, 5:27 pm
Screen Blinking When Selecting URLs February 26, 2005, 12:55 am
ampersand in urls when using xhtml 1.0 strict December 17, 2007, 8:30 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap