How to change:
domain.com/go/?custom_ref=001
into
domain.com/go/?ref=001
using htaccess rewrite please?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not particularly flexible, but this works for your exact problem:
Note that for the condition to match,
refmust come first in the query string. The[QSA](Query String Append) flag on the rule will retain the original query string, so other values passed will not be lost.Also note that this code assumes the .htaccess file is in the document root. If the file is elsewhere, you will need to adjust the
RewriteRule. For example, changing it to the following will work when the .htaccess file is placed at /go/.htaccess:If you want this to be more flexible, check out the responses to this question – they contain the syntax for changing a single variable in the query string and retaining everything else.
Edit:
To replace
custom_refwithrefin the query string, you could use the following to redirect requests containing thecustom_refvariable. Add this betweenRewriteEngine Onand the other rules:This is more of a patch than a solution. If you have access to the code, I recommend fixing the variable names there instead.