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 am struggling to achieve this simple thing...

I have some static pages which should be like etc.. The problem is how to write the rewrite rules in order to ..

There would be some fixed rewrites like /home

I want every file that exists not to be rewritten should go to test.php

Lastly if it is not found i want it to be redirected to static.php?_.....

RewriteRule ^/home/?$ /index.php?__i18n_language=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([^/]+)/?$ /static.php?__i18n_language=$1     

This works ok but if i type index.php or test.php or even the mach from other redirection it gets me in static.php... Please help!

share|improve this question

migrated from Oct 30 '10 at 14:16

This question came from our site for pro webmasters.

When it comes to how to do mod_rewrite serverfault is the right place for the question to be asked. Moving this there now. – John Conde Oct 30 '10 at 14:16
up vote 1 down vote accepted

First of all, your

RewriteRule ^/home/?$ /index.php?__i18n_language=$1 [L]

is using a parameter ($1) ... but there is nothing in the first section that defines what that parameter should be.

The second section

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([^/]+)/?$ /static.php?__i18n_language=$1 
  1. is missing [L], which is a good idea to have

  2. uses request url as a parameter to i18n which means it works something like: -> /static.php?__i18n_language=login

Can you give some more examples of what kind of urls you are trying to query, what you expect to happen, and what you see happening?

You might want to use the RewriteLog Directive to create a log and try to debug your mod_rewrite problems.

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.