Htaccess防止页面扩展显示


htaccess prevent page extensions displaying

我已经设置了我的htaccess文件,这样我的网站页面就不需要显示扩展名,我的链接是这样设置的,在末尾有斜杠:

 www.mywebsite/about/

这些链接可以工作-但是如果我直接键入

 www.mywebsite/about.html 

该网站将显示此页面与html扩展。有一种方法,我可以防止扩展显示,即使他们直接输入?: S

我的大部分页面都是html,除了一个php页面。这是我在我的htaccess:

中的内容
Options -Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/$ $1.html [L]
RewriteRule ^php-page/([^/'.]+)/?$ php-page.php?p=$1 [L]
如果有人能帮我解决这个问题,我将非常感激!:)

请试试:

Options -Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} ^(.*)'.html$
RewriteRule .* %1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/$ $1.html [L]
RewriteRule ^php-page/([^/'.]+)/?$ php-page.php?p=$1 [L]

我认为可以做得更好一点,但应该可以。