I have a site with two possible base urls:

http://example.com
http://example.com/~username

I can get clean URLS to work on one or the other but not both.

How can I set the RewriteBase to either / or /~username depending on the address requested?

Thanks in advance!

Comments

bwv’s picture

This is done in the .htaccess file. Have you looked there for this line:

#Rewritebase /

Uncomment and amend as necessary.
----------------------------------------------------------------------
http://www.bwv810.com/

I am a writer and researcher. In my spare time I build websites with Drupal.
Je peux communiquer en français. / Я могу общаться на русском языке.

matt_harrold’s picture

Yeah, I know how to get one scenario working but not both. I need to conditionally modify the Rewritebase to either / or /~username depending on the requested url.

On my server, you can only access your site via http://server.com/~username prior to domain delegation (both after delegation), and this means I have to keep Clean URLs turned off (or modify .htaccess) when the domain starts working. I was hoping that there is some Apache conditional "thingy" I can put in .htaccess.

Anyone know what "thingy" looks like?

In pure nonesensical pseudocode, I'd imagine it would look like

if domain is http://myserver.com
Rewritebase /~username
else
Rewritebase /
endif
bwv’s picture

If you have a distinct installation in the subdirectory, amend the .htaccess file there as you did in your example above, to wit:

Rewritebase /~username
----------------------------------------------------------------------
http://www.bwv810.com/

I am a writer and researcher. In my spare time I build websites with Drupal.
Je peux communiquer en français. / Я могу общаться на русском языке.

matt_harrold’s picture

There is only one installation of Drupal, I need the ability to selectively configure the Rewritebase depending on which domain is used to access the site.

My server generates an instant domain alias for each account using the username (http://server.com/~username).
Once delegated, the domain associated with this account will not have the ~username extra bit.=, and Clean URLs break.

Therefore, my difficulty is this ... if I want Clean URL support using BOTH domains, I need a way to tell mod_rewrite that the Rewritebase should be different.