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

On our virtual host, we have defined our document root to point to var/www/something/public

Since we have that, do we need, on our .htaccess file (that will be placed on public directory btw), this?

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule .? /public%{REQUEST_URI}

Thanks in advance, MEM

share|improve this question
If my questions doesn't make sense, please let me know as well. :) – MEM Mar 27 '11 at 11:12
up vote 1 down vote accepted

No. you don't need specify rewrite rules in .htaccess for this case.

Suppose you have a file named index.html in var/www/domain/public and you configured this directory as the DocumentRoot for

Then will work.

share|improve this answer
Correct me I'm wrong: I may need to specify rewrite rules in .htaccess files. But don't need this particular rule because it's redundant. Is that it? – MEM Mar 27 '11 at 11:23
Actually you need not to worry about the folder name "public". Setting DocumentRoot means all files in DocumentRoot must serve for every http request. – Suku Mar 27 '11 at 11:33
True, but If I need to redirect to a specific file, for example, for index.php especificly, and if I would like to avoid hotlinking on hosted images, for those both cases, I would need to have a rewrite rule, but the one on my question, that one, in particular, is redundant. Yes? - I'm just trying to make perfectly clear and be certain that I'm not making rules on my htaccess file that I don't need to. Hence all this questioning. :) – MEM Mar 27 '11 at 11:37
Since you have already specified the document root to be the following /var/www/domain/public you dont have to explicitly write these rules in the .htaccess as both means the same. – Suku Mar 27 '11 at 11:52
Thanks a lot. :) . – MEM Apr 24 '11 at 17:25

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.