在.htaccess中强制尾随斜杠 - http和https页面

时间:2017-01-30 09:50:12

标签: apache .htaccess magento mod-rewrite

我想在Magento网站上强制使用尾部斜杠。在正常情况下,下面的代码工作正常。但是,此站点有一些https页面,例如登录和结帐页面。我想知道我如何在htaccess文件中解释这个问题?我假设我需要为这些https页面设置单独的规则吗?

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.domain.com/$1/ [L,R=301]

感谢。

1 个答案:

答案 0 :(得分:0)

您可以使用它来强制HTTPshttp的斜杠:

RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 

确保在测试之前清除缓存。