I try to convert a url parameter in folders using RewriteRule.
Anyone can help me?.
Origin: search.php?term=red&cat=colors
Destination: /search/red/colors
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.
The top part of this answer clarifies how URLs get rewritten and redirected. Using “convert” is not really clear, as there’s 2 completely different things that can happen.
To change a URL like
/search.php?term=red&cat=colorsto the nicer looking variation, you need to match against the actual request and redirect the browser:This makes it so when someone types in their browser the URL:
http://mysite.com/search.php?term=red&cat=colors, they get externally redirected tohttp://mysite.com/search/red/colors, changing the URL in the address bar.Then in order to internally rewrite the nicer looking URL and route it back to the php script:
This does the reverse, but only internally so that the URL in the browser’s address bar remains unchanged while the content is served from
search.php. You can do one or the other depending on what your need is, or you can do both if you need this to happen in both directions.