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

Context: How can I configure a NameCheap domain to point to an Apache subfolder?

Following Devin's answer here I've created a .htaccess file in /var/www and wrote in the following:

RewriteEngine On

RewriteCond !
RewriteRule (.*)$1 [QSA]

My folder structure is such:


When visiting the URL I see the contents of /var/www when I would like to be directly redirected to /var/www/

Any ideas?

share|improve this question

From your question, i think you don't need to use rewrites here, but you should change your DocumentRoot within your VirtualHost block to point to the right directory. So for instance:

DocumentRoot /var/www/
share|improve this answer

A . in a regular expression is a special character (it means "any character except \n"), so you'll need to escape it.


RewriteEngine On

RewriteCond !sergiotapia\.me
RewriteRule (.*) sergiotapia\.me/$1 [QSA]
share|improve this answer
It still doesn't redirect despite escaping the regex. Do you think I need to restart the Apache service first? Edit: Restarted service and still no dice. :( – sergserg Nov 18 '12 at 21:07

Check your virtual host configuration for AllowOverride (Probably within a section).

If AllowOverride is None .htaccess is not parsed. Set it to All might help...

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.