Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make it so that all requests that use a subdomain are rewritten in such a way that they are sent to the server as "regular" request without the subdomain. I have created the mod_rewrite code below but it doesn't seem to be working. Any advice is greatly appreciated.

Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*?)*)$2

I want everything to still appear in the user's address bar window as:$2

(where $2 is whatever path they originally entered in the address bar)

share|improve this question

The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string. If you wish to match against the hostname, port, or query string, use a RewriteCond with the %{HTTP_HOST}, %{SERVER_PORT}, or %{QUERY_STRING} variables respectively.

in other words, just lose the host and you are all set

RewriteCond %{REMOTE_HOST} !  # prevents loops
RewriteRule /(.*)$2
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.