1

I know how to rewrite in the reverse direction and process the Query String, but I need to create one query string parameter based on the tag or category, in lowercase. Therefore, I can user the query string as search parameter in my page:

e.g.

news/tag/Shipping/ ==> http://www.example.com/news/?tag=shipping
news/category/Other/ ==> http://www.example.com/news/?category=other

Tried

RewriteEngine On
RewriteRule ^news/([^/]*)$ /?tag=$1 [L]

Thank you.

1
  • 1
    Can you share what you have tried? Commented Apr 14, 2017 at 6:26

1 Answer 1

1

You need 2 rewrite rules.

RewriteEngine On

RewriteRule ^news/([\w-]+)/?$ news/?tag=$1 [L,QSA,NC]

RewriteRule ^news/([\w-]+)/([\w-]+)/?$ news/?$1=$2 [L,QSA,NC]
Sign up to request clarification or add additional context in comments.

2 Comments

Anyway that Tag or Category could just be assumed to be in the same position in the URL and the final part of the URL is the variable part. I only added Tag to my code to try and make it work correctly. @anubhava.
In the 2nd rule you can notice that both 2nd and 3rd parts are variables. That should work for all the cases. If you have a different requirement then edit the question with examples.

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.