0

I've tried and tried and tried by my htaccess knowledge isn't great, and I cannot find anything to suit my needs (but then I'm not sure what i'm searching for).

Effectively my question is twofold:

I want to convert: http://subdomain.domain.com/hello
To: http://subdomain.domain.com/index.php?string=hello

But occasionally there could be a querystring as well so...
From: http://subdomain.domain.com/hello?query=true
To: http://subdomain.domain.com/index.php?string=hello&query=true

So far I've managed the first:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([^/\.]+)/?$ client.php?user=$1&$2 [L]

Remember, the second is a potential :) Thanks!

1 Answer 1

1

You just need to set the QSA flag for the last rule:

RewriteRule ^([^/\.]+)/?$ client.php?user=$1 [L,QSA]

Then the original requested query will automatically appended to the new one.

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

1 Comment

Ah... it's always the simplest solution! Thank you!

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.