How do i add trailing slash to the end of the URL with .htaccess rewrite rules
I would like to know that how do i add trailing slash to the end of the URL with .htaccess rewrite rules. Can any body tell me that how can i do so? Does any body knows about it? Kindly provide me the correct logical solution for the above issue. Would be grateful to you if any body helps me out to resolve the above issue.
Re: How do i add trailing slash to the end of the URL with .htaccess rewrite rules
Following is the code for redirecting all urls that doesn't have a trailing slash to urls with a trailing slash.
Quote:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
The first line tells Apache that this is code for the rewrite engine of the mod_rewrite module of Apache. And the 2nd line sets the current directory as page root. But the interesting part is following now:
Quote:
RewriteCond %{REQUEST_FILENAME}
Re: How do i add trailing slash to the end of the URL with .htaccess rewrite rules
Whenever you use mod_rewrite (the part of apache that does all this magic), you need to do. You only need to do this once per .htaccess file:
Quote:
Options +FollowSymlinks
RewriteEngine on
Note: +FollowSymLinks must be enabled for any rules to work, this is a security requirement of the rewrite engine. Normally it's enabled in the root and you shouldn't have to add it, but it doesn't hurt to do so, and I'll insert it into all the examples on this page, just in case*.