Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 22-05-2009
Member
 
Join Date: Jan 2009
Posts: 84
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.
Reply With Quote
  #2  
Old 22-05-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
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}
Reply With Quote
  #3  
Old 22-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
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*.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How do i add trailing slash to the end of the URL with .htaccess rewrite rules"
Thread Thread Starter Forum Replies Last Post
How to get rid of Slash character from Date in Excel HangDown MS Office Support 2 16-02-2012 07:16 PM
Double Slash after .com jamiehook01 Tips & Tweaks 1 27-09-2011 12:34 AM
Norton Safe Web Verification Causing Problems with Rewrite Rules Rupashri Networking & Security 3 17-09-2010 06:27 AM
Samsung LN52B750 Image Trailing/Ghosting Issue Amuda Monitor & Video Cards 6 06-05-2010 09:54 AM
Keep trailing zero in ms access for generating reports Noverism Windows Software 3 06-06-2009 05:23 PM


All times are GMT +5.5. The time now is 01:47 AM.