.htaccess MOD_REWRITE - URL结尾的尾随斜杠

kqlmhetl  于 2022-12-04  发布在  其他
关注(0)|答案(1)|浏览(154)
Options -Indexes +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC] 
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ HTTP%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 

ServerSignature Off

RewriteRule ^cookie-policy/?$ cookie_policy.php [NC,L]`

你好,我正在努力与网址结束尾随斜线。

RewriteRule ^cookie-policy/?$ cookie_policy.php [NC,L]

例如,我想强制从www.website.com/cookie-policy重定向到www.website.com/cookie-policy/

ovfsdjhp

ovfsdjhp1#

使用此选项:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]

它会在你的网址末尾添加一个/。请确保在测试之前清空你的缓存。

相关问题