Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 currently have

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ ^$1 [QSA,L]

Which is fine if I have a single site, but I didn't realize this would mess up every other domain on my server (yikes!.

I basically only want to rewrite$1 to remove the index.php and create a clean URL on that domain and not show the index.php... apologies for the noob question.. how do I need to approach this?

share|improve this question
You should have separate <VirtualHost> entries for each domain on your server, and typically, none of them should be sharing directories. Something is very strange about your setup. Can you describe it in much more detail? – Michael Hampton Jan 29 '13 at 6:45
You're right, they shouldn't share directories, but since these are not really production level sites and are used simple for experimentation two sites do share the same directory... (which creates problems, as I realize) – wnajar Jan 29 '13 at 18:11
up vote 0 down vote accepted

While I agree with Michael Hamptons response, here's a quick fix to do what you want:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{HTTP_HOST}
    RewriteRule ^(.*)$ ^$1 [QSA,L]

As you see, I added the condition that the Host header be, in addittion to requiring that the file is nonexistent.

Kudos to you for using your actual hostname, it makes it a lot easier to help!

share|improve this answer
That's what I needed. Also worth noting that that code isn't actually correct, the rewriterule should be RewriteRule ^(.*)$ index.php/$1 [QSA,L] – wnajar Jan 29 '13 at 18:17
You're completely right about the RewriteRule, sorry I missed that - I was just focusing on the conditions! – Jenny D Jan 30 '13 at 7:34

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.