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?

Recommended Answers

All 5 Replies

Have you cleared your cache? If you have removed the .php file from your file manager/server then it should stop displaying once you've deleted temporary files.

If you haven't removed it from your file manager it may also show up if you haven't updated your internal web links. Also DNS may be taking it's time to update.

Hi Cleo123,

I think, I have not made myself clear. I have .php files which are written and the same files have been re-written using mod_rewrite through .htaccess. As I have mentioned in my first thread, when I am a rewriting my existing url, example.com/index.php to example.com/index.html.

Rewriting is doing its fantastic job, but the problem lies at when I go manually to example.com/index.php, that is also accessible.

With this rewriting, I might face some issues in terms of seo, as search engine robots may consider this as duplicated urls (which can be avoided through canonical system) but that does not help my visitors as they see two different urls with same information.

How can I not display the original .php file after rewriting it to .html...

Request to help.... thanks

I've never tried this, but it should be possible to redirect the .php with a 301 to the .html but you should be careful not to create an endless loop.

Another option would be to rename all your .php files to .html and add a handler in your htaccess to treat them as php files.

dear friend,

my website is built in php and i want to redirect it to html. i cannot change php to html because i have cart attached to it. So its not possible.

But thanks for your kind reply.

I've never tried this, but it should be possible to redirect the .php with a 301 to the .html but you should be careful not to create an endless loop.

Another option would be to rename all your .php files to .html and add a handler in your htaccess to treat them as php files.

Member Avatar for diafol

I'm slightly confused here.

Is there any reason why you need .html instead of .php?
As Pritaeas states, you can change your .htaccess to accept php coding within .html files. So you can just rename .php files to .html.

Does the cart insist you use .php files?

The whole point of rewrites AFAIK is that you can apply certain 'new fancy zingy url patterns' that the server will read as 'the original long ugly urls'. The old urls should still work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.