R
R
Rostislav2017-01-15 02:44:48
Apache HTTP Server
Rostislav, 2017-01-15 02:44:48

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

2 answer(s)
R
Rostislav, 2017-01-15
@boarworm

I answer myself.
This kind of redirect worked:

RewriteCond %{QUERY_STRING} ^p=(\d+)/
RewriteRule ^(.*) /$1?p=%1 [R=301,L]

H
honormgr, 2017-01-15
@honormgr


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 question

Ask a Question

731 491 924 answers to any question