1

For a website, I want using URL rewriting to allow easy access to pages and better indexation.

For instance, assume the page about Mozart is:

www.site.ext/composers/index.php?cmd=composers&id=123

Instead of this, I would like that the visitors enter: www.site.ext/Mozart and reach the same page.

I also want that robots from search engines index the "friendly" address and be unaware of the "unfriendly" real address.

Both .htaccess files below work and give access to the same content.

In the browser, the first one keeps the friendly url in the address bar (i.e. www.site.ext/Mozart),

#Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#AllowOverride all
RewriteCond %{HTTP_HOST} .
RewriteRule ^Mozart$ composers/index.php?cmd=composers&id=123 [L]

whilst the second, with the additional R=301 option, makes a permanent redirection to the "unfriendly" address:

#Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#AllowOverride all
RewriteCond %{HTTP_HOST} .
RewriteRule ^Mozart$ composers/index.php?cmd=composers&id=123 [R=301,L]

As the category names will never change over time, I assume that the first case --URL rewriting only without perceivable redirection-- is better in this situation as search engines would store and display the friendly url instead of the unfriendly one. Is this indeed the case?

Concerning the internal links accross the site (i.e. anchors in pages), I assume that I should use PHP (or equivalent) to dynamically write their friendly URL version instead of the default unfriendly one, so that search engines won't index unfriendly URL.

As a complement, to avoid indexation of duplicate URLs (in case of omissions in the code), I assume it would be wise to mention in each page its friendly URL as canonical link:

<head>
...
<link rel="canonical" href="http://www.site.ext/Mozart" />
...
</head>  

Are above assumptions correct or are there contraindications?

  • 1
    For questions about SEO, consider visiting our sister site Webmasters which focuses heavily on this. Also, be sure that your application follows the front controller pattern, having one and only one entry point. – Michael Hampton Apr 19 '18 at 16:53
  • Thanks for mentioning the Webmasters sister site. I did not know its existence. – OuzoPower Apr 19 '18 at 17:40
1

As the category names will never change over time, I assume that the first case --URL rewriting only without perceivable redirection-- is better in this situation as search engines would store and display the friendly url instead of the unfriendly one. Is this indeed the case?

Yes.

Concerning the internal links accross the site (i.e. anchors in pages), I assume that I should use PHP (or equivalent) to dynamically write their friendly URL version instead of the default unfriendly one, so that search engines won't index unfriendly URL.

Yes. Only link to the friendly/"pretty" URL. The real/"ugly" URL is never exposed to users, search engines or bots of any kind. The real/"ugly" URL is entirely internal to your application.

The only additional step you might have to do is if this was an older site and the old/"ugly" URLs had already been indexed by search engines or linked to by external sites. In which case you would also have to implement external 301 redirects from the old/"ugly" URL to the new/"pretty" URL in order to preserve SEO.

I assume it would be wise to mention in each page its friendly URL as canonical link

Yes, you can do that. This also ensures that any (erroneous) URL parameters don't get indexed.

Are above assumptions correct

Yes.

  • Thank you MrWhite! As 99% of site was "ajaxified" there were no old pages referenced. So, I hope not having to do 301 redirects (unless search engines were too fast at indexing it.) – OuzoPower Apr 19 '18 at 17:44

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.