[英].htaccess Force Trailing Slash Rewrite
Apologies but I'm fairly new to URL Rewrites. 不好意思,但是我对URL重写还很陌生。 I've managed to get the rewrite working in the conventional sense but cannot force it to have a trailing slash.
我已经设法使重写工作按常规意义进行了,但是不能强迫其后面加上斜线。
Here is the code: 这是代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html [L,QSA]
You can try: 你可以试试:
RewriteEngine On
RewriteBase /
# add a trailing slash for non-files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)/?$ $1.html [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.