在htaccess中添加和删除尾部斜杠

时间:2017-04-30 21:19:43

标签: php apache .htaccess mod-rewrite

我试图写一些条件来添加不带.html的尾随斜杠或重定向网址,并从/

的网址中删除.html

例如:

https://www.example.com/page -> https://www.example.com/page/
https://www.example.com/page.html/ -> https://www.example.com/page.html

这是我的.htaccess

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/]+$ %{REQUEST_URI}/ [L,R=301]

我做错了什么?

0 个答案:

没有答案