3

Posts on my website can be reached by URLs like this long version

http://example.com/post/22/do-your-home-work-for-free

or URLs like this short version

http://example.com/post/22/

I want to use PHP code to redirect all the short URLs to long URLs. Would that make search engine think badly about mysite?

  • I wouldn't think so with a proper 301 redirect. Just make sure you redirect the short URL to the long URL for performance reasons. If you can, I would prefer not to link to the short URLs or have them in any site map as well. – closetnoc Dec 26 '15 at 17:15
  • That short url is for sharing on social network, it's necessary for my case. The long url is for SEO as you already known. Having one and only url would benefit more I think, that's why redirecting. – angry kiwi Dec 26 '15 at 17:31
  • I understand the reason for the short URL. Not knowing the business of social media, being staunchly anti-social by nature, I get how the shorter URL would be handy. If the shorter URLs are used for social media, and the longer URLs used exclusively on the site and within any sitemap as well as for inbound (back) links (primarily), you may be okay. – closetnoc Dec 26 '15 at 19:06
3

Having a single URL for each page is known as URL Canonicalization. Canonicalizing the URL for each page has been an SEO best practice for ten years or more. The search engines won't think badly of you for redirecting your short URLs to your long URLs, doing so may even improve your rankings.

This StackExchange site implements redirects for canonicalization. There are short sharing URL. (Click the "share" links and see for yourself.) These short URLs and incorrect URLS all redirect to the correct full URL for this question:

  • http://webmasters.stackexchange.com/q/88265/14543
  • https://webmasters.stackexchange.com/questions/88265/
  • https://webmasters.stackexchange.com/questions/88265/wrong-question-title

You can implement URL canonicalization with either 301 permanent redirects, or by using link rel canonical tags in the head section of your pages. See the Google help document on using canonical URLs for more information.

| improve this answer | |
  • don't think I can do the 301 redirect for this case. There might be so many posts to add to htaccess file. – angry kiwi Dec 27 '15 at 3:53
  • You would usually program these redirects in PHP as you mentioned in your question. The other option of the canonical tags is fine as well if you can't do the redirects. – Stephen Ostermiller Dec 27 '15 at 9:33
  • I see that StackExchange uses 302 redirects for this purpose, not 301. Why? – SlimShaggy Nov 3 '17 at 10:36
  • @SlimShaggy They use 301 as far as I can tell: curl --head https://webmasters.stackexchange.com/questions/88265/wrong-title gives HTTP/1.1 301 Moved Permanently – Stephen Ostermiller Nov 3 '17 at 10:46
  • @StephenOstermiller but webmasters.stackexchange.com/q/88265/14543 gives 302 – SlimShaggy Nov 3 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.