.htaccess url rewrite unwanted ?q= in result

Hello guys.

I need to perform an url rewrite on certain pages of the website. I’ve tried to do so with RewriteRule as well as with RedirectMatch but I keep getting unwanted query parameter at the end of the url

RewriteRule ^(.*)catalog/category/does-not-exist$ https://example.com/ [R=301,L]

results in Example Domain
instead of just domain name

I’ve also tried Redirector extra but it does the same thing - adds the ?q= to url

I know that this q= parameter is important for internals and such, but how do I get rid of it when it’s not needed? Maybe there is a setting I’m missing?

MODX version 3.0.1-pl, Redirector version 2.0.11-pl

This doesn’t make much sense. The q parameter should never be visible.

Can you share the rest of the .htaccess file?
In the line RewriteRule ^(.*)$ index.php?q=$1 [L,QSA], to you use a redirect R=301 as well?

Here’s the htaccess, it’s pretty much the same as the original except for .html removal

RewriteEngine On
RewriteBase /

Force rewrite .html extention to none

RewriteRule ^index.html$ / [R=301,L]
RewriteRule ^(.*)/index.html$ /$1 [R=301,L]

RewriteRule “^.well-known/” - [L]
RewriteRule “/.|^.(?!well-known/)” - [F]

Rewrite to non-www

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.
)$ https://%1/$1 [R=301,L]

Force rewrite to https for every host

RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{SERVER_PORT} !^443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Oh I’ve got it wrong, the proper rule for rewriting one-liner would be

RewriteRule ^(.*)catalog/category/does-not-exist$ $1 [R=301,L]

but only if (.*) is the https:// with domain name and nothing else, which suits me in my situation.

Rule from the first message would have no effect because (.*) in the first argument is https:// and the domain name, and it rewrites it with… the same thing from the second argument. Sorry for the time waste.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.