好吧,也许我是转储,但我的简单重写.htacces规则不起作用。我只想在我的网站上例如www.mysite.com/something.html重写规则www.mysite.com/something。我想要删除.html并从文件something.html获取内容
现在我在.htacces文件中有这个,但没有工作:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
AddType application/x-httpd-php5 .htm .html
答案 0 :(得分:2)
您需要另一条规则来重定向.html
:
RewriteEngine On
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
AddType application/x-httpd-php5 .htm .html