Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 添加尾部斜杠并删除.htaccess_Apache_.htaccess_Mod Rewrite_Trailing Slash - Fatal编程技术网

Apache 添加尾部斜杠并删除.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

我怎样才能做这样的事情: 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
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]