Abdul Qadir Nadeem Abdul Qadir Nadeem -4 years ago 108
Apache Configuration Question

.htaccess 301 redirect conflicting with rewriterule

I am trying to redirect the URL but its conflicting with the rewrite-rule, I am using this redirection Rule

Redirect 301 /antique-vintage-rugs/170-antique-oriental-rugs-carpets https://example.com/antique-vintage-rugs/170-antique-rugs

it took me to this link
https://example.com/antique-vintage-rugs/170-antique-rugs?action=clear&template=170-antique-oriental-rugs-carpets instead of this

My Rewrite URL is this

RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^antique-vintage-rugs/(.+) results.php?action=clear&template=$1 [NC]

Is there any way I can get the desired output redirect link?

Answer Source

You need to only be using mod_rewrite here instead of mixing it with mod_alias (where the Redirect directive belongs). When you mix the two, both end up processing the same request.

So instead of Redirect, use:

RewriteRule ^antique-vintage-rugs/170-antique-oriental-rugs-carpets https://example.com/antique-vintage-rugs/170-antique-rugs [L,R=301]

but make sure it's before your other rules.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download