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've googled this but can't seem to figure out.

I'm looking to simply redirect any path requested to a GET parameter in index.php:

RewriteEngine on
RewriteBase  /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/.+\.(js|css|png|jpg|gif|ico)$

RewriteRule ^(.*)$ http://localhost/site/index.php?request_url=http://%{HTTP_HOST}%{REQUEST_URI} [L,QSA]

Now, redirect works but it's painfully slow, and gets executed twice.

Do I have to add another condition that checks whether request_url is already there? If so, how do I write that? Can't seem to figure out.

Right now it's not exactly a redirect loop, just really slow.

Any help appreciated.

Thanks a 1000!

share|improve this question

Does it help if you change your rewrite rule to:

RewriteRule .* /site/index.php?request_url=http://%{HTTP_HOST}%{REQUEST_URI} [L,QSA]

The main difference is to remove the leading http://localhost from the target. That might help because if %{HTTP_HOST} is different from localhost, then Apache will issue an external redirect: see the paragraph titled "Absolute URL" in the RewriteRule documentation. That will take twice as long, as you say.

I also simplified the match pattern to just .*, but this is just a minor cleanup. There's no need for the constraining matches ^...$, and no need to capture with (...) either since you're not using the captured value in the rule target.

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.