Redirect "URL with Trailing Slash" to "URL without Trailing Slash"?

Discussion in 'Apache' started by mrintech, Mar 20, 2012.

  1. #1
    Redirect URL with Trailing Slash to URL without Trailing Slash?

    I need help as I am confused a lot with .htaccess

    Some months back, I removed WWW from the URL of my domain name using following .htaccess lines:

    RewriteCond %{HTTP_HOST} !^example.com$ [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

    Now, I also want to remove the trailing slash from the URL, as because I am using WordPress and a page/post will open, no matter if there's a trailing slash or NOT!

    I request you to please provide me the .htaccess code, so that I can REMOVE the trailing slash and redirect any URL with trailing slash in it TO the URL without Trailing Slash. Kindly remember, I don't want WWW also and I have already set .htaccess rule for the removal of WWW

    Note: 3 Years back when I started the blog, I set the Permalinks Structure without trailing slash. Now, suddenly Google Webmasters Tools is showing warnings. I mean to say, both of these URLs are opening the same page/post:

    http://example.com/about/

    and

    http://example.com/about

    Also, the URL for rel="canonical" is WITHOUT trailing slash

    If you require any more details, I will be happy to provide

    Regards
     
    mrintech, Mar 20, 2012 IP