Forum Moderators: phranque

Message Too Old, No Replies

Facing limits of RewriteCond use

         

zyron

3:42 pm on Jul 8, 2005 (gmt 0)

10+ Year Member



Hi!

I'm strugling with a challenge I don't know if there is a solution to.

I have a webhotell with dedicated IP that I want to handle multiple domains with, using .htaccess.

And I want it fully automatic, so that if there is a folder already - it will get the files from that folder.

--
RewriteCond %{HTTP_HOST} (www\.)?([^\.]+\.com)$
RewriteCond /home/www/sub/%2 -d
RewriteCond %{REQUEST_URI} /([^/]+)
RewriteCond /home/www/sub/%2/%1 -d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule (.*)$ %2/%1/$1 [L]

It seems like %2 is being lost when %1 is created... do anyone have a solution to this kind of challenge?

Regards
Lars

jdMorgan

8:12 pm on Jul 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since REQUEST_URI is also available to RewriteCond in $1, you could use something like:

RewriteCond %{HTTP_HOST} (www\.)?([^.]+\.com)
RewriteCond /home/www/sub/%2/$1 -d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^/]+)$ /%2/$1 [L]

If you could provide some example URLs (using example.com and example2.com as domain names) and the URL-paths you want them rewritten to, it would make it easier to understand the subtleties of what you're trying to do here.

Jim

zyron

3:23 pm on Jul 9, 2005 (gmt 0)

10+ Year Member



Hi!

Moving Request URI should do the trick yeah.
I also discover that using [envŠE=VAR:VAL]
and %{ENV:VAR} will enable me to make more complex matches...

Thanks!
Lars