。htaccess中的强制斜杠

问题描述 投票:1回答:2

这是我当前的.htaccess文件:

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /

# Force https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Header set X-UA-Compatible "IE=Edge,chrome=1"

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

如果没有一个斜杠,我该怎么办?例如,我当前的网址如下所示:

https://amemoirproject.com/chapters/quarter-after

我想用斜杠结尾,所以它们看起来像这样:

https://amemoirproject.com/chapters/quarter-after/

.htaccess mod-rewrite
2个回答
5
投票
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ http://%{HTTP_HOST}/$1/ [L,R=301]

0
投票

我应该在哪里粘贴这些行?

© www.soinside.com 2019 - 2024. All rights reserved.