Read About the latest SEO News and Updates

Wednesday, April 2, 2014

How to Redirect .php to .html via .htaccess?

Please get the 301 redirection code for .php to .html via .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourwebsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} \ /(.+)\.php
RewriteRule ^ /%1.html [L,R=301]
RewriteRule ^(.*).html$ $1.php [QSA]

ErrorDocument 404 /404.html

No comments:

Post a Comment