S
S
Super0leg2018-08-16 14:42:37
Apache HTTP Server
Super0leg, 2018-08-16 14:42:37

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]

But it always gives a 301 redirect, even if there is no such page

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question