[英]htaccess trailing slash redirect with Kirby
Is it possible to redirect a url without trailing slash to the URLs with trailing slash in Kirby CMS ? 在Kirby CMS中是否可以将不带斜杠的URL重定向到带斜杠的URL? How?
怎么样?
From 从
http://www.test.com/page http://www.test.com/page
To 至
http://www.test.com/page/ http://www.test.com/page/
htaccess file 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]
Finally I found it, works on localhost as well. 最终,我找到了它,也可以在localhost上运行。
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
http://www.paulund.co.uk/using-htaccess-to-force-trailing-slash http://www.paulund.co.uk/using-htaccess-to-force-trailing-slash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.