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
Regex Can';t在没有尾部斜杠的情况下重定向到url_Regex_.htaccess - Fatal编程技术网

Regex Can';t在没有尾部斜杠的情况下重定向到url

Regex Can';t在没有尾部斜杠的情况下重定向到url,regex,.htaccess,Regex,.htaccess,这是我的.htaccess Options -Indexes ServerSignature Off RewriteEngine On RewriteBase / # Redirect to index.php RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_METHOD} !HEAD RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Rewr

这是我的
.htaccess

Options -Indexes
ServerSignature Off
RewriteEngine On
RewriteBase /

# Redirect to index.php
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_METHOD} !HEAD
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# Enable compression
<FilesMatch "\.(html?|txt|css|js|php|pl)$">
    SetOutputFilter DEFLATE
</FilesMatch>

# Caching control
<IfModule mod_headers.c>
    Header set Cache-Control "max-age=86400"
    Header set Pragma "max-age=86400"
    Header set Expires 0
</IfModule>

# Redirect to https
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# Redirect from www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$  [NC]
RewriteRule ^(.*) https://%1/$1 [L,R=301]

但是没有一个有效

好的,这一个有效:

RedirectMatch ^(.+)/$ $1
RewriteCond %{REQUEST_URI} ^([^.]+)/$
RewriteRule ^[^.]+/$ /%1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) https://example.com/$1/ [R=301,L]
RewriteCond %{QUERY_STRING} ^(.+)/$
RewriteRule ^ %{REQUEST_URI}?%1 [L,R=301,NE]
RedirectMatch ^(.+)/$ $1