473,803 Members | 3,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.co m/>

Jul 3 '08 #1
4 4872
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.co m/>

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.co m/>

Jul 6 '08 #5

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

Similar topics

7
3478
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 not there, but it doesnt work.. any ideas?
4
5092
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 run the mencoder with the needed params, but now I want to integrate mencoder as a subprocess in my app. What already works: the starting of the subprocess.Popen and the subsequent killing of the process if I want it to.
10
1874
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") The Gecko based browsers change this URL to read "Validation BookingNo=1234567" and of course they get a 404 Error as a result. The above code works on every other browser without fault. So why do Gecko based
0
2588
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) command line utility as redirecting its input and output so I can interact with this one. This utility is similar to ftp under a win32 console. It proposes its own prompt after launching it.
3
2336
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 main page from the code behind the contents page. I want to do this to allow the use of asp "linkbuttons" instead of hyperlinks so I can do a little processing before redirecting. The main reason for this to prevent hyperlinks of pages that have...
4
1498
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 are redirecting to somewhere that doesn't exist. Worse, if you do type it correctly, but then later the page name changes or the page moves, you still won't find out until run time. I have a framework that solves this problem and guarantees,...
8
5791
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 technically create an executable that calls the function and then using a command prompt call the exexutable using the > output.txt redirector but I would prefer to do everything within the application itself. Is there a way for force an output...
17
9469
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 redirect: Response.Redirect("/website/pdffiles/myreport.pdf"); Response.End; IE opens a "File Download" box and if you click the "open" button then
41
3254
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 resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
0
1160
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 set my custom Remember be cookie on the login page. Following are the details: 1. Authentication mode is ‘Forms’ 2. This issue is reproducible only in deployed applications, I found this using my trace and remote debugging 3. This issue occurs...
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10550
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.