jessiecarey
jessiecarey

Reputation: 1

htaccess mod_rewrite query string path

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

Upvotes: 0

Views: 72

Answers (1)

Croises
Croises

Reputation: 18671

You can use:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^d=(.+)$ [NC]
RewriteRule ^(.+)/?$ %1/$1? [L]

Upvotes: 1

Related Questions