[英].htaccess remove extension from URL with ending / folder
I am using the current code to remove .shtml
from my URLs for a project of mine: 我正在使用当前代码从我的项目的URL中删除
.shtml
:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ $1.shtml
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.shtml
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
It is working perfectly till I make more than one subfolder, such as /folder1/folder2/
, then it can not find the folder 2 argument. 直到我制作多个子文件夹(例如
/folder1/folder2/
,它才能正常工作,然后找不到文件夹2参数。 I am not even sure where to go from here to make it work (I don't have much experience at using .htaccess
) 我什至不知道从哪里可以使它正常工作(我没有使用
.htaccess
丰富经验)
why not just replace these two lines: 为什么不只替换这两行:
RewriteRule ^([^/]+)/$ $1.shtml
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.shtml
with 与
RewriteCond %{DOCUMENT_ROOT}/$1.shtml -f
RewriteRule ^(.*)/$ /$1.shtml [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.