多次尝试后添加Trailing Slash .htaccess失败

时间:2015-12-15 13:05:07

标签: .htaccess url mod-rewrite

我几乎尝试了所有解决方案,但没有取得成功

这些是我在htaccess文件上尝试的尝试

1

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$

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

2

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$

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

3

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
<IfModule mod_rewrite.c>
 RewriteCond %{REQUEST_URI} /+[^\.]+$
 RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>

4

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

完全沮丧......可以做些什么呢?

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.
RewriteRule !.+/$ %{REQUEST_URI}/ [L,R=301]