【发布时间】:2015-02-11 12:09:53
【问题描述】:
对于某些 URL,我的 htaccess 无法正常工作。我只想将文件的扩展名如php重写为html。但它不起作用。当我输入像“http://www.example.com/myfile.php”和“http://www.example.com/myfile.html”这样的 URL 时,两个 url 都在工作。但我只想将 myfile.php 重写为 myfile.html。
我的 htaccess 重写规则是:-
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Options -Indexes
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^index\.php$ "http\:\/\/example\.com\/" [R=301,L]
Header unset Pragma
FileETag None
Header unset Last-Modified
Header unset ETag
RewriteRule ^myfile.html$ myfile.php [QSA,L]
ServerSignature Off
【问题讨论】: