简体   繁体   中英

Rewriting Query String URL in htaccess with 301 Redirect

I have tried to find a solution to my problem in the other asked questions on Stackoverflow, but though there a lot of such questions answered for the exact same question yet it is different because I am asking as to how I should define more than two query strings in the ReWrite Condition,

I am trying to do a 301 redirect on a query string URL:

http://abc.com/index.php?arg1=abc&arg2=abc

to mask it as

http://abc.com/prettified_url

,and have tried using the following code in htaccess:

RewriteRule ^http://abc.com/index.php?arg1=abc&arg2=abc$ /prettified_url  [R=301,L,NC]

have also tried using:

RewriteCond %{HTTP_HOST} !^.*abc\.com
    RewriteRule .? - [S=2]
    RewriteCond %{REQUEST_URI} ^index.php
    RewriteCond %{QUERY_STRING} ^arg1=abc [NC]
    RewriteCond %{QUERY_STRING} arg2=abc [NC]
    RewriteRule ^(.*)$ /prettified_url [R=301,L]

    RewriteRule .? - [S=1]
    RewriteRule - -

have also tried using the following code in the query string ReWrite Condition:

RewriteCond %{QUERY_STRING} ^arg1=abc&arg2=abc [NC]

Though, I am not able to see it being redirected to /prettified_url .

Try with below one :

RewriteCond %{QUERY_STRING} ^arg1=abc&arg2=abc
RewriteRule (.*) http://abc.com/prettified_url? [L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM