If Page Extensions Changes from .html to .php

Got a question lately where a friend of mine is moving his site from a static HTML website to a .php website. One of his questions where if he needed to add a redirect from his Old URLs to his New URLs, where the the only changing part in his URL structure is the Extension. For Example:

  • Old Url: /wissam-dandan.html
  • New URL: /wissam-dandan.php
Unfortunately, Yes! Google Sees these as 2 different pages and a 301 redirect is needed to preserve the link juice and so it can be transferred (most of it) to the new URL.
Luckily the only variable in this move is the extension which it can resolve with  a 3 line of code in .htaccess to make this a successful move:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [R=301]
This solution will redirect OLD URLs using a 301 Redirect to new one’s .
On the OTHER Hand, i would approach this problem from a different way, if I was involved from the beginning. what i would do is use the Mod_rewrite and rewrite the URLs so they don’t have any Extensions. This way when your changing CMS platforms or even software used (PHP/ASP/ASPX) all the URLs will be the Same.

Comments

1comments
  • author avatar
    Santosh Jena
    1 year ago Reply

    Great information for extension change…
    @Wissam…let me know how can i change in .asp to .aspx?

Leave a Reply

css.php