0

I'm trying to rewrite a query string in Apache.

The current (example) domain is: example.com/?domain=domain.com

I would like this to then be rewritten into: example.com/domain.com

So, when a user enters: example.com/?domain=domain.com

They are always redirected to the pretty version: example.com/domain.com

I've tried quite a few different rewrites, such as:

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

But this fails to work (i.e. nothing happens) with .htaccess and ModRewrite enabled.

Any help would be greatly appreciated.

1 Answer 1

2

Try this -

RewriteCond %{QUERY_STRING} ^domain=(.*)$
RewriteRule ^(.*)$ http://example.com/%1? [L]

Empty question mark at the end is important as it will discard the original query string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.