473,386 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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


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/>

Jul 3 '08 #1
4 4844
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.i...0f7baad24c74dc

Dunno. It's a nearly 3-year old thread you were actually involved in,
so perhaps it doesn't work.
Jul 4 '08 #2
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.
Jul 4 '08 #3

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.i...0f7baad24c74dc
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/>

Jul 4 '08 #4

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.i...0f7baad24c74dc

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/>

Jul 6 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: spearman | last post by:
what is wrong with <?php if(!stristr($_SERVER, 'www')) { Header("Location: http://www.theSpear.net" . $_SERVER); exit(); } ?> I am trying to make it redirect to www.theSpear.net if www. is...
4
by: Ivo Woltring | last post by:
Hi Pythoneers, I am trying to make my own gui for mencoder.exe (windows port of the terrific linux mencoder/mplayer) to convert divx to Pocket_PC size. My current app creates a batch script to...
10
by: Kenneth Keeley | last post by:
Hi, I have been having problems with Gecko based browsers not redirecting properly. This is the line of code that does the redirecting: Response.Redirect ("Validation.asp?BookingNo=1234567") ...
0
by: Christophe HELFER | last post by:
hi, I have some problem with redirecting input and output from a process. I can only use VB language (sorry...) Situation: I have to use the Cisco Network Registrar (DNS And DHCP server) ...
3
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the...
4
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you...
8
by: Morpheus | last post by:
I am trying to test a function that outputs text to the standard output, presumably using a cout call. I do not have access to the source, but need to test the output. Is this possible? I can...
17
by: mansb2002 | last post by:
Hi, We recently moved our webserver from Win2K to Win2003. The application works fine. Only problem is that when user views a report as a PDF, IE does not show it. The following code is used to...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
0
by: Anup Daware | last post by:
Hi All, I am facing this very weird issue, for every server request my control is redirecting to the login page and again coming back to the actual page from where the request was initiated when I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.