Answer the question
In order to leave comments, you need to log in
How to remove the slash at the end of a link that has query parameters in htaccess?
There is a link: http://mysite.com/articles?p=3/
Need to do: http://mysite.com/articles?p=3
That is, without a slash at the end
These are pagination pages, so you need to take into account that the "p" parameter can have other values
Answer the question
In order to leave comments, you need to log in
I answer myself.
This kind of redirect worked:
RewriteCond %{QUERY_STRING} ^p=(\d+)/
RewriteRule ^(.*) /$1?p=%1 [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
Please note that this method may not always work if the URL requires a mandatory slash, for example site.com/user/ the user will be redirected to site.com/user, of course, with the parameters preserved.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question