Search code examples
php.htaccessurl-rewritingtrailing-slashkirby

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? How?

From

http://www.test.com/page

To

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

htaccess file

<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>

Solution

  • Finally I found it, works on localhost as well.

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

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