WordPress.org

Ready to get started?Download WordPress

Forums

Handle Trailing slashes at the end of URL (1 post)

  1. sabhandari
    Member
    Posted 1 year ago #

    There is clear cut advantage of using consistent URL structure for wordpress website.

    I want all of my URL's to end with / (the homepage and internal page URL's). Let me give an example website which is handling it very efficiently so that the URL's without ending with slash or ending with multiple slashes are 301 redirected to URL with single slash.

    http://viralpatel.net/blogs 301 redirect to viralpatel.net/blogs/

    http://viralpatel.net/blogs// 301 redirect to viralpatel.net/blogs/

    http://viralpatel.net/blogs/ 200 OK

    http://viralpatel.net/blogs/check-string-is-valid-date-java 301 redirect to http://viralpatel.net/blogs/check-string-is-valid-date-java/

    http://viralpatel.net/blogs/check-string-is-valid-date-java// 301 redirect to http://viralpatel.net/blogs/check-string-is-valid-date-java/

    http://viralpatel.net/blogs/check-string-is-valid-date-java/ 200 OK

    Any idea what .htaccess rules can help achieve this. My current .htaccess looks like:

    RewriteEngine On
            RewriteCond %{HTTP_HOST} ^javaexperience.com [NC]
            RewriteRule ^(.*)$ http://www.javaexperience.com/$1 [R=301,L]
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]

Topic Closed

This topic has been closed to new replies.

About this Topic