-13 Votes

HTACCESS: Crop Trailing Slash from the end of a URL

Tip by Stefan Trost | 2013-04-16 at 03:54

Today, I would like to show you, what you can write into your .htaccess to remove the trailing slash from the end of a requested URL and to redirect the request to the address without slash automatically.

Simply write the following line to your .htaccess:

RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

With this, all requests of the form:


Will be redirected to:


When redirecting, we automatically send the status code 301 (Moved Permanently). This shows search engines, for example, that only the new URL should be in force.


About the Author

AvatarYou can find Software by Stefan Trost on sttmedia.com. Do you need an individual software solution according to your needs? - sttmedia.com/contact
Show Profile


Related Topics


Tutorial | 0 Comments

How to avoid Spam Mails

Tip | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.