Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

How can I set the rewrite base of the rewrite engine to

#access site via
RewriteBase /~sitename/

when it's accessed via and set it to

#access site
RewriteBase /

when it's accessed via

I'd like to have some sort of switch or condition. Because now when I set the RewriteBase to one of the options, the site is not functional when trying to access it with the other url.

EDIT: New site same problem.... so is this unsolvable?

share|improve this question

Put it withing tags in you config. Something along the lines of the following might do:

<Directory /path/to/document/root>
    RewriteBase /

<Directory /home/sitename>
    RewriteBase /~sitename

For the ~sitename case you may want to place it in a .htaccess istead to more easily define it for different users.

If these are in different vhosts you also have to specify

RewriteEnging On

for both of them.

share|improve this answer
In fact this rule is in the .htaccess, also I can't get this to not create a server error. – Moak Aug 12 '09 at 13:23

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.