.php url到.html网址

sam*_*t23 3 php mod-rewrite webserver url-rewriting

我有一个内置的网站,.php但我们已经.html使用"mod rewrite"将其转换为.使用的mod重写代码.htaccess

RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php
Run Code Online (Sandbox Code Playgroud)

现在问题是我的网站出现在.php.html.

例如:www.mydomain.com/index.html还有www.mydomain.com/index.php.

据我所知,它不利于搜索引擎的目的,也可能是搜索引擎的重复内容.

所以我想只保留.html [not .php]搜索引擎和用户的网址.

怎么做?

Cri*_*iss 6

更新 incoorperated评论(谢谢你们)

添加另一个重写规则,将所有*.php重定向到其他规则之前的*.html文件.类似的东西:

RewriteRule ^(.*).php$ $1.html [R=301,QSA,L]
Run Code Online (Sandbox Code Playgroud)

使用永久重定向(301)将所有php文件重定向(R标记)为html并停止处理其他所有内容(L标志).它还转发所有查询参数(QSA标志)