Mobile app version of vmapp.org
Login or Join
Phylliss660

: Wrong URL Requested But I know what they meant - 404 vs canonical vs 301 redirect I'm using mod_rewrite to process variables in the URL. For many of my URLs the final portion of the string

@Phylliss660

Posted in: #301Redirect #CanonicalUrl #ModRewrite #Soft404

I'm using mod_rewrite to process variables in the URL. For many of my URLs the final portion of the string doesn't matter because I'm not using it. For instance:

/review/company-25/jb-hunt


I'm only using the "company-25" portion to tell me which company is being requested (company # 25). The "jb-hunt" portion isn't needed. It's only to make a pretty URL for SEO purposes or whatever.

Well sometimes the final portion of the string might be wrong but I know what page they're requesting. For instance, someone links to my site with a typo. They meant to link to:

/review/company-25/jb-hunt


But they accidentally linked to:

/review/company-25/jbhunt


I know they want company #25 but the URL is wrong. How should I handle this?

From a user's standpoint I should probably redirect them to the correct page instead of issuing a 404. This is easy to do.

But what about from an SEO standpoint?


Would a 301 redirect be the way to go even though the page being requested never existed?
Should I show the page anyhow using the wrong URL but use a canonical tag to point search engines to the correct URL? (probably not)
Should I issue a 404 and say the heck with the user experience? (probably not)
Can I issue a 404 for the original request but then redirect the user to the correct page without them even knowing that the original was a 404?


What's the best way to handle this?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Phylliss660

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

tl;dr You should 301 redirect to the canonical URL. This is for the benefit of SEO, as much as user experience.

You already know the correct resource to return (based on the company-25 part of the URL), so returning a 404 instead of correcting the URL seems a bit of a waste (and wasted SEO). Since you must already be doing the necessary lookups server-side in order to determine the slug is not as expected.



Would a 301 redirect be the way to go even though the page being requested never existed?



Well, the page does exist (based on the ID part of the URL). But the URL is mistyped - so correct it.



Should I show the page anyhow using the wrong URL but use a canonical tag to point search engines to the correct URL? (probably not)



The canonical tag gets around the duplicate content issue. And search engines should return the canonical URL in the results. However, a redirect is a far stronger signal and prevents the invalid URL being propagated by users. Just redirect.



Should I issue a 404 and say the heck with the user experience? (probably not)



And the heck with SEO? You know the correct URL - just redirect.



Can I issue a 404 for the original request but then redirect the user to the correct page without them even knowing that the original was a 404?



Messy, difficult/impossible to implement properly. If you issue a 404 then you can't issue a 3xx status as well. It would need to be a JavaScript (200) redirect. Users and search engines will see the 404 first.

Incidentally, this is what StackExchange does (ie. redirect incorrect slugs). The added benefit is that when titles change and hence the URL slug changes, the page automatically redirects to the canonical URL.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme