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 have a vhost in which I would like to rewrite / to something like /cgi-bin/script?123. I thought something like this would work, but this rewrites to "/index.html/ somehow.

RewriteEngine On
RewriteRule ^/$ /cgi-bin/script.cgi?123 [L]

How can you do this?

share|improve this question
up vote 1 down vote accepted

Maybe try the following:

RewriteEngine On
RewriteRule ^/?$ /cgi-bin/script.cgi?123 [L]
share|improve this answer
Strange. With that, it returns the correct document, but the URL itself isn't rewritten; it stays the same! – Jens Björnhager Nov 17 '09 at 4:39
Hi Jens, So is that what you are looking for? If not, could you give me a couple of examples of input and output you are looking for? Are you trying to redirect the user to a different page or are you trying to define the exact script that gets triggered/loaded when they go to a particular site/url? – malonso Nov 20 '09 at 22:27
I just want to (silently) redirect "[/]" to "" – Jens Björnhager Feb 20 '10 at 1:00
Sorry, I was thinking that you want to keep the URL the same but load a different page. If you want to redirect the user's browser to another page, change "[L]" to "[R=302,L]". I put a 302 redirect in there as an example but you should determine if that is really the correct one to use: – malonso Feb 21 '10 at 22:32
Excellent, thanks. There was some problem with reply notifications, sorry for high latency :) – Jens Björnhager Apr 26 '10 at 15:49

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.