0
所以我有这样的网页:使用htaccess的斗篷HTML页面的文件夹
/features.html
我想刚才
/features
RewriteEngine on
RewriteRule ^(.*)$ *PATH*.html
的链接到这个网页文字*PATH*
应该采取的文件夹路径,并追加.html
它,如果路径中结束EXCEPT 210
所以我有这样的网页:使用htaccess的斗篷HTML页面的文件夹
/features.html
我想刚才
/features
RewriteEngine on
RewriteRule ^(.*)$ *PATH*.html
的链接到这个网页文字*PATH*
应该采取的文件夹路径,并追加.html
它,如果路径中结束EXCEPT 210
按照你的逻辑,你会在到达:
RewriteEngine on
#If path ends in a forward slash, don't rewrite
RewriteRule ^(.*)/$ - [L]
#If path ends in .html, don't rewrite (avoiding an infinite loop)
RewriteRule ^(.*)\.html$ - [L]
#Otherwise add .html to the end (note this will apply to images too)
RewriteRule ^(.*)$ $1.html
但是,这会影响到其他的扩展,以及如图像。我建议检查文件是否存在或不是这样的:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ $1.html
是的,我马上找到了images/css/jss没有加载! :-) –