Reputation: 31
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?
Upvotes: 3
Views: 2819
Reputation: 1211
UPDATE incoorperated comments (thanks guys)
add another rewrite rule which redirect all *.php to *.html files before your other rule. something like that:
RewriteRule ^(.*).php$ $1.html [R=301,QSA,L]
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)
Upvotes: 6
Reputation: 12805
Easiest way is to simply deny ".php" in your robots.txt.
User-Agent: *
Disallow: *.php
All proper spiders will obey this instruction
Upvotes: 0
Reputation: 187
Can you not just rename the .php files to .html and delete the RewriteEngine rules? The PHP should still all run as expected.
Upvotes: 0