Answer the question
In order to leave comments, you need to log in
How to remove the slash at the end of the url in .htaccess, but at the same time, if there is no such page, send a 404 error?
Search engines try to find different non-existent pages on the site by type /feed/, /comments/
And instead of a 404 response, they get a 301 redirect
To remove the slash at the end, I use:
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question