Results 1 to 3 of 3

Thread: How do i add trailing slash to the end of the URL with .htaccess rewrite rules

  1. #1
    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.

  2. #2
    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.

    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:
    RewriteCond %{REQUEST_FILENAME}

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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:
    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*.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,926,003.03286 seconds with 17 queries