0

I've seen and implemented rewrite urls that convert query strings to paths and vice versa. I'm still not very good at writing custom rules and I haven't seen an example where the query string's converted path is re-written as the first subdirectory of a URL.

Using htaccess rewrite rules, is this possible? www.website.com/?d=test rewrites to www.website.com/test and www.website.com/about/?d=test rewrites to www.website.com/test/about and www.website.com/about/overview/?d=test rewrites to www.website.com/test/about/overview

1
  • It is, it's just not typically useful - paths are often rewritten to query strings so that the back-end can process them more conveniently while the URLs look more readable. Commented Dec 19, 2015 at 23:14

1 Answer 1

1

You can use:

RewriteEngine on RewriteCond %{QUERY_STRING} ^d=(.+)$ [NC] RewriteRule ^(.+)/?$ %1/$1? [L] 
Sign up to request clarification or add additional context in comments.

1 Comment

Could you please edit in an explanation of why this code answers the question? Code-only answers are discouraged, because they don't teach the solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.