簡體   English   中英

使用Kirby的htaccess尾部斜杠重定向

[英]htaccess trailing slash redirect with Kirby

Kirby CMS中是否可以將不帶斜杠的URL重定向到帶斜杠的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>

這個怎么樣

    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

最終,我找到了它,也可以在localhost上運行。

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM