00 Votes

HTACCESS: Cut Slash and And-Character (/&) from URL

Question by Mail Request | 2017-03-26 at 13:17

How is it possible to remove a slash and a following &-character from a web address? Constantly, I get requests to my website with "/&" attached to the URL. However, those pages are not existing and therefore I always get lots of 404 error messages. Thanks in advance!

ReplyPositiveNegative
0Best Answer0 Votes

You can try the following Rewrite Rule in your HTACCES-file:

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

This should redirect URLs like "askingbox.com/test/&" to "askingbox.com/test". If you additionally also wants to redirect URLs without &-character, you can use both of the following RewriteRules:

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

These rules are caring about that "askingbox.com/test/" as well as "askingbox.de/test/&" will be redirected to "askingbox.de/test".
2017-03-26 at 17:27

ReplyPositive Negative
Reply

Related Topics

HTACCESS: Simplify URL

Tutorial | 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.

Participate

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