homepage Welcome to WebmasterWorld Guest from 54.226.213.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect double forward slash
troyid




msg:4265372
 9:20 pm on Feb 10, 2011 (gmt 0)

I have tried all sorts of rewrite rules in htaccess but nothing I use works.

I need to redirect

http://www.example.com/news//news/page.html

to

http://www.example.com/news/page.html

 

g1smd




msg:4265377
 9:31 pm on Feb 10, 2011 (gmt 0)

What code have you tried so far?

There's some previous threads with example code:
[google.com...]

wilderness




msg:4265379
 9:34 pm on Feb 10, 2011 (gmt 0)

I have tried all sorts of rewrite rules in htaccess but nothing I use works


There's multiple old thread on this topic in both this forum and Search Engine Spider Forum.

Generally speaking though, I found these double slashes were almost always caused by active links in my own pages that I'd missed correcting. The numbers will continue to propagate until your repair your syntax errors on your own pages.
There are many html tools that will do these kinds of editing in seconds as opposed to making the corrections manually.

troyid




msg:4265380
 9:39 pm on Feb 10, 2011 (gmt 0)

There is nothing pointing to the bad url on my site. Maybe an external site is linking to it. I only picked up on it because Google has indexed it.

I have searched this forum and found various suggestions. Too many to list. None of them worked.

g1smd




msg:4265383
 9:48 pm on Feb 10, 2011 (gmt 0)

Without knowing what you have already tried and in exactly what way it "didn't work" there's no way to suggest any fixes.

troyid




msg:4265790
 7:04 pm on Feb 11, 2011 (gmt 0)

I have tried these to remove the double slashes.


# Externally redirect to remove multiple contiguous slashes at beginning or end of URL
RewriteCond %{REQUEST_URI} ^//+(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*/)/+$
RewriteRule / http://www.example.com/%1 [R=301,L]

# Externally redirect to remove multiple contiguous slashes embedded in URL
RewriteCond %{REQUEST_URI} ^/([^/]+)//+(.*)$
RewriteRule // http://www.example.com/%1/%2 [R=301,L]

This had no effect.

g1smd




msg:4265822
 8:04 pm on Feb 11, 2011 (gmt 0)

Was that code placed in http.conf or in .htaccess?

What exactly do you mean by "no effect"?

jboy




msg:4266145
 4:28 pm on Feb 12, 2011 (gmt 0)

surely "no effect" means when he accessed the page with a double slash, it wasn't redirected.

wilderness




msg:4266198
 6:54 pm on Feb 12, 2011 (gmt 0)

jboy,
Your relatively new here and perhaps you don't understand what g1smd was asking?

Of course he understands the redirect failed, however what he requesting is specific details (not previously provided) on how the redirect failed and how it failed as to what was intended to take place.
One example is what were the results of the failed redirect in the error logs.

from the forum charter [webmasterworld.com]:
Please describe your server environment and include whatever research and testing you've done so far. This will help the members who are willing to help you, and increase their number, too. Better, more-detailed questions get faster, better, and more-detailed answers, since the other members won't have to ask you for more information.
end of quote

In addition there are numerous examples (specific questions that require answers) provided by jdmorgan on far too many occassions which provide step-by-step interpretation of "no effect".

g1smd




msg:4266256
 10:55 pm on Feb 12, 2011 (gmt 0)

Indeed.

What HTTP status code was returned for the request?
What content or error message was seen?
What is in the server error log, if anything?

Otherwise, the only answer to give to "no effect" is, "it's broken".

jdMorgan




msg:4268698
 9:50 pm on Feb 17, 2011 (gmt 0)

The code is correct, so something else is wrong -- possibly mod_rewrite is not set up and/or enabled on this server. So I have to add another question:

Do you have any currently-working mod_rewrite rules in this file?

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved