.htaccess htaccess集成将尾部斜杠添加到现有规则
我在htaccess文件中做了几件事:.htaccess htaccess集成将尾部斜杠添加到现有规则,.htaccess,.htaccess,我在htaccess文件中做了几件事: 强制https 删除www 删除index.php 我正在使用代理(Cloudflare) 如何将尾部斜杠添加到URL中?我有这个片段,但当然,简单地添加它会给我多个重定向: RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !index.php RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)
- 强制https
- 删除www
- 删除index.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]
第二个
RewriteCond
中缺少斜杠。这应该起作用:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/index\.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]
我还转义了
index.php中的
谢谢,但我想在第一个代码段中添加尾部斜杠函数,从而保留现有函数(强制https、删除www等)
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/index\.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]