.htaccess 重定向到跟踪斜杠(htaccess)
尝试将尾部斜杠添加到每个链接。i、 e.应该使301重定向到etc,但如何?以下是htaccess:.htaccess 重定向到跟踪斜杠(htaccess),.htaccess,apache2,.htaccess,Apache2,尝试将尾部斜杠添加到每个链接。i、 e.应该使301重定向到etc,但如何?以下是htaccess: RewriteEngine on DirectoryIndex index.php Options -Indexes RewriteBase / RewriteCond %{REQUEST_URI} \.css$ RewriteCond %{QUERY_STRING} ^pack$ RewriteRule ^(.*)$ /modules/system/css_compactor.php?fil
RewriteEngine on
DirectoryIndex index.php
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_URI} \.css$
RewriteCond %{QUERY_STRING} ^pack$
RewriteRule ^(.*)$ /modules/system/css_compactor.php?filename=$1 [L]
RewriteCond %{REQUEST_URI} \.js$
RewriteCond %{QUERY_STRING} ^pack$
RewriteRule ^(.*)$ /modules/system/js_compactor.php?filename=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php
RewriteRule /admin/(.*)$ /admin/index.php
需要帮助 这是我正在使用的
RewriteEngine on
RewriteBase /
### CHECK FOR TRAILING SLASH - Will ignore files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]
基本上,这可以确保它不会向文件添加尾随,而只添加文件夹或路径
编辑
使其独立于域
RewriteRule ^(.*)$ $1/ [L,R=301]
用RewriteRule^(.*)$[L,R=301]替换最后一行RewriteRule^(.*)$$1/[L,R=301]