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

Example: My Site gets called like that:

Now, .htaccess needs to rewrite this URL into:

But the problem is: In case of an img, css or js directory, no redirection should happen.

How can I achieve this? I only know the mod-rewrite engine is my friend here.

share|improve this question

To complete Khal Weir's answer, the resulting rule should be something like :

RewriteBase /
RewriteCond %{REQUEST_URI}!^(/css/|/js/|/images/|/robots.txt)
RewriteRule . /index.php/ [L]
share|improve this answer

Either you filter it as the other recommended it or you filter for files existing on the hard drive:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php/ [L]

These days most CMS systems filter it like this.

share|improve this answer
+1 This is actually a "better" way to do it than what I proposed. – François Feugeas Feb 12 '10 at 17:08

You can do something like the following:

RewriteCond $1 !^(css|js|images|robots\.txt)
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.