Apache 添加尾部斜杠并删除.htaccess
我怎样才能做这样的事情: website.com/store/重定向到website.com/store website.com/outbound/store/5重定向到website.com/outbound/store/5/ 我想要的是,对于没有前缀的URL,删除尾部斜杠,对于那些有前缀的URL,添加尾部斜杠 我的.htaccess:Apache 添加尾部斜杠并删除.htaccess,apache,.htaccess,mod-rewrite,trailing-slash,Apache,.htaccess,Mod Rewrite,Trailing Slash,我怎样才能做这样的事情: website.com/store/重定向到website.com/store website.com/outbound/store/5重定向到website.com/outbound/store/5/ 我想要的是,对于没有前缀的URL,删除尾部斜杠,对于那些有前缀的URL,添加尾部斜杠 我的.htaccess: Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f R
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^pa/?$ /admin/index.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ stores.php?store=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^outbound/([^/]*)/([^/]*)$ /outbound.php?type=$1&id=$2 [L]
我还把它清理了一点。前缀是什么意思?前缀指的是最后一行“outbound”中的常量
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# force tailing slash for all urls starting with /outbound/
RewriteRule ^outbound/.*[^/]$ /$0/ [R=301,L]
#remove tailing slash for all except urls starting with /outbound/
RewriteCond $1 !^outbound/
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule ^pa/?$ /admin/index.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^outbound/([^/]*)/([^/]*)/$ /outbound.php?type=$1&id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ stores.php?store=$1 [L]