Q:

mod_rewrite: How can I rewrite a url with slash?

I can rewrite mydomain.comto www.mydomain.com, that's OK. 
But, I just couldn't figure how to rewrite:
http://mydomain.com/great-article to http://www.mydomain.com/great-article.
How can this be done with regex? Any help would be appreciated.

A:

This shall work:
RewriteCond %{HTTP_HOST}   ^mydomain\.com$
RewriteRule .*             http://www.mydomain.com/$0 [L,R=301,QSA]

I.e. every request to
http://mydomain.com/something
will get redirected to
http://www.mydomain.com/something.
As well as simple requests
http://mydomain.com/
will go to
http://www.mydomain.com/.
And due to Query string append (QSA) - this shall work for such URI
http://mydomain.com/index.php?action=hello&param=world
to get redirected to
http://www.mydomain.com/index.php?action=hello&param=world.
Or am I missing something?

