Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect will not work for certain URL's

Most URL's redirect fine - some dont, please help!

         

ltweb

6:05 pm on Apr 1, 2012 (gmt 0)

10+ Year Member



Hi there I am having trouble getting all of the URL errors inside google webmaster to redirect. Most of the URL's I have redirected work fine but I am having trouble redirecting the following URLs. I have found plenty of advice online but nothing seems to be working for me. Any help would be much appreciated.

/specifications/Maintenance%20Manual%20V%201... (The dreaded %20! What is the best way to redirect these?)

/specifications/Understanding-Raised-Floor-Systems-for-the-Specifier.. (cannot work out why this will not redirect as I have successfully redirected very similar URLs)

/world/english/web/body/?wb_url=google.co.jp&wb_lp=ENJA&wb_dis=3 (Im guessing this wont redirect because of the query string - whats the best method to redirect this?)

Thank you in advance for any advice you can give me on this subject. I hope this thread can help people out in future going through the same problem I am having.

g1smd

6:56 pm on Apr 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Without seeing the code, it's impossible to point out the simple typo or logic error in that code.

Use a RewriteRule for each one. The one to fix requests with query string will also need a preceding RewriteCond looking at QUERY_STRING. All rules will need the R=301 and L flags.

ltweb

7:53 pm on Apr 1, 2012 (gmt 0)

10+ Year Member



Thank you very much for your response - is there any way you can simplify what you mean? Perhaps even with an example as I havent a clue what you mean.

incrediBILL

9:31 pm on Apr 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Please show us the actual redirect code you're using as we have no clue based on just the URLs themselves. There are many possible solutions to your problem, not just one absolute right or wrong answer, so we kind of need to see how you are attempting to solve the problem in order to offer potential corrections to your implementation.

ltweb

9:56 pm on Apr 1, 2012 (gmt 0)

10+ Year Member



Thanks very much for your response.

redirect 301 /world/english/web/body/?wb_url=google.co.jp&wb_lp=ENJA&wb_dis=3 http://www.example.com

redirect 301 /specifications/Understanding-Raised-Floor-Systems-for-the-Specifier.. http://www.example.com

redirect 301 /specifications/Maintenance%20Manual%20V%201... http://www.example.com

There is a long list of URL's in my htaccess file all setup this way and they redirect fine so just need to know what im doing wrong here or what is the best alternative.

Again many many thanks for this!

[edited by: incrediBILL at 10:18 pm (utc) on Apr 1, 2012]
[edit reason] fixed examples - removed (dot) from (dot)com [/edit]

g1smd

10:03 pm on Apr 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Redirect is the wrong tool for the job.

Use RewriteRule instead. There's 30 000 previous threads with related discussion. Pick a random ten threads and get reading.

Use RewriteRule for all of your rules. Never mix Redirect and RewriteRule in the same site. It will lead to chaos.

ltweb

10:13 pm on Apr 1, 2012 (gmt 0)

10+ Year Member



Okay cheers buddy i'll get reading! Thanks for your help :-)

g1smd

10:17 pm on Apr 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Post code here for critique when you're ready.

Use example.com to suppress URL auto-linking.

lucy24

12:18 am on Apr 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oops, one question that should have been asked before all others:

Do the errors involve requests for actual pages that have moved, or are we talking about URLs that g### invented out of thin air? (Not literally thin air. Usually by misreading something that was never meant to be an URL in the first place-- especially likely when you see trailing ..)

You are not obliged to do anything with URLs that don't exist-- unless it's a real and valued link that got misspelled at the other end, and you're waiting for them to fix it. Otherwise, on the Errors page, just flag the bogus links as Fixed and move on.

If any of your page names really contain literal spaces-- the things that turn into %20 --the only permanent fix is to get rid of 'em. The spaces, I mean. Not the pages ;) Meanwhile, if there are only a few of them you can nab them with individual Rewrites. If there are spaces all over the place, you'll need to point them to the equally dreaded PHP Script, because the only mod_rewrite alternative is to keep redirecting over and over until it rinses clean. This is Not A Good Idea.

ltweb

9:58 pm on Apr 2, 2012 (gmt 0)

10+ Year Member



Thanks Lucy - I think you've hit the nail on the head there I shouldnt worry about these bogus links at all should I? Just one final question - there is a pdf for example on the server with spaces in the name and that pops up now and again in g### webtools. If I remove the spaces from the title of the PDF will this not just create a whole host of new crawl errors as there will be links on the internet to this PDF with the spaces in the name? Thank you very much for your input.

dougwilson

5:03 pm on Apr 3, 2012 (gmt 0)

10+ Year Member Top Contributors Of The Month



redirect urls with spaces
/.htaccess

RewriteRule ^Folder/3600\ Years\ Ago.html (to) hxxp:// etc

g1smd

5:08 pm on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You forgot to escape the literal period in the RegEx pattern.

This rule will also need the [R=301,L] flags.

ltweb

6:48 pm on Apr 3, 2012 (gmt 0)

10+ Year Member



Makes absolutely no sense whatsoever to me Doug but thanks anyway.

lucy24

8:37 pm on Apr 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If there's one specific file that you need to redirect, you can keep it as a straight htaccess rule:

RewriteRule ^blahblah/name(\ |%20)with(\ |%20)spaces\.pdf http://www.example.com/name-without-spaces.pdf [R=301,L]

The (\ |%20) pieces mean: By the time this request arrives at your server, the literal spaces have probably changed into your friend %20. In case they haven't, you need to allow " " as an option. But a space has syntactic meaning in mod_rewrite (in generic Regular Expressions it doesn't) so you have to escape it with a backslash \ the same way you escape the literal period in \.pdf.

Keep this Redirect in place until all external links have caught up. After that, you might change it to a simple - [G] to tell the search engines to stop looking for the old with-spaces name.