I have a website built in .php
but we have converted it to .html
by using "mod rewrite". the mod rewrite code used in .htaccess
is
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php
Now the problem is my website shows up in both .php
and .html
.
for example: www.mydomain.com/index.html
and also www.mydomain.com/index.php
.
as per my knowledge its not good for seo purpose and also it may fall in duplicate content to search engines.
so i want to keep only .html [not .php]
url live on search engines and for users.
how to do that?
Easiest way is to simply deny ".php" in your robots.txt.
All proper spiders will obey this instruction
Can you not just rename the .php files to .html and delete the RewriteEngine rules? The PHP should still all run as expected.
UPDATE incoorperated comments (thanks guys)
add another rewrite rule which redirect all *.php to *.html files before your other rule. something like that:
that redirects (R flag) all php files to html with a permanent redirect (301) and stops processing everything else (L flag). also it forwards all query parameters (QSA flag)