Forum Moderators: phranque

Message Too Old, No Replies

301 redirect help

         

cheaperholidays

10:37 am on Oct 6, 2011 (gmt 0)

10+ Year Member



Hi all. I have posted this in the php forum, but its not a database error its google picking up links form other sites.

I wonder if you can help?

We have a travel advice blog and we are getting odd urls showing up as 404 errors.

This is such an error example.com/travel/foreign-travel-advice-portugal/2011/06/01/.Portugal

The correct url is example.com/travel/foreign-travel-advice-portugal/2011/06/01/

How can i make sure that only the correct url is shown, i have tried url redirect plugins but they only keep the structure correct not remove additions to the url

They would take this url example.com/travel/foreign-travel-advice-portugal/

and replace it with:

example.com/travel/foreign-travel-advice-portugal/2011/06/01/


Kind regards

Mike

lucy24

6:03 pm on Oct 6, 2011 (gmt 0)

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



The good news is that you have come to the right place. The bad news is that many other people have also come here for the same reason, which means that you're expected to find an existing, up-to-date answer by searching the last page or two of threads. This would be easier if people used nice descriptive post titles, but it can't be helped.

In fact you have cleverly combined two of the most common questions:

The search engines are adding weird stuff to my url (probably from third-party links that are out of your power to fix)
AND
I need to redirect people from the right place to the wrong place.

It sounds as if your "redirect plugins" are in fact RewritePlugins, meaning that what they only change what the user sees, not what's really going on.

Your basic pattern is

RewriteCond {various stuff that only you can know}
RewriteRule {old URL here} {corrected URL here} [R=301,L]

If your example is typical, you have one head start. You don't have to mess with bogus query strings. You just need to get rid of the extra. Only you can figure out how to make it fit into a pattern.

So start trying things, and post back when you've got it almost figured out. Or when you thought you had it perfect and your server hit you with 500 hahaha things you overlooked.