0

是否可以将不带斜杠的 url 重定向到Kirby CMS中带有斜杠的 URL ?如何?

http://www.test.com/page

http://www.test.com/page/

.htaccess 文件

<IfModule mod_rewrite.c>
DirectorySlash On
RewriteEngine on
RewriteBase /test/kirby/
RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]
RewriteRule ^site/(.*) error [R=301,L]
RewriteRule ^kirby/(.*) error [R=301,L]
RewriteRule ^robots.txt robots.txt [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
4

2 回答 2

0

这个怎么样

    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
于 2014-03-11T10:06:27.850 回答
0

最后我找到了它,它也可以在 localhost 上工作。

RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

http://www.paulund.co.uk/using-htaccess-to-force-trailing-slash

于 2014-03-13T11:39:31.513 回答