0

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

MEM
  • 119
  • 1
  • 7

1 Answers1

1

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 1sample1.com.

Then http://1sample1.com/index.html will work.

Suku
  • 2,036
  • 13
  • 15
  • 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
  • 1
    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
  • 1
    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