1

There is number of similar .htaccess questions, but even after lengthy search I haven't been able to find an answer to my problem.

I recon it should be fairly simple, it's just beyond my abilities.

I need to redirect add a parameter to extend search parametr with another - specifically I need this:

www.domain.com/?s=whatever

to become

www.domain.com/?s=whatever&post_type=product

each and every time, but obviously only when s parameter is present and post_type parameter is not.

Doing this the right way (managing the parameters at input) is unfortunately impossible in this case, that's why I want to bypass this with .htaccess.

Thanks a lot for your help!

1
  • Why not have that as the default in server side language? Commented Aug 23, 2016 at 14:47

1 Answer 1

1

You can use this rule in site root .htaccess:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^s=[^&]+ [NC]
RewriteRule ^ %{REQUEST_URI}?post_type=product [QSA,L,R=302,NE]
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for your insanely fast answer, it worked :) !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.