httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <jos...@slive.ca>
Subject Re: [users@httpd] Mod_rewrite - Removing www on dynamic domain names
Date Thu, 10 Jun 2004 22:55:11 GMT

On Thu, 10 Jun 2004, Chris tunnell wrote:

> The webserver I run has multiple domains.  To add
> domains, I create a folder in /var/www/ for the
> domain.
>
> On the apache side, I run this code so that I don't
> have to create many virtual hosts:
>
> RewriteMap  lowercase  int:tolower
> RewriteCond  %{REQUEST_URI}  !^/icons/
> RewriteCond  /var/www/${lowercase:%{SERVER_NAME}} -d
> RewriteRule  ^/(.*)$
> /var/www/${lowercase:%{SERVER_NAME}}/$1 [L]
> RewriteCond  %{REQUEST_URI}  !^/icons/
> RewriteRule  ^/(.*)$  /var/www/null/$1
>
> How do I have it so that when somebody requests
> www.foo.com, this links to /var/www/foo.com.  I cannot
> figure out how to do this with regex though.  How can
> I do this?
>
> Removing the "www" is not preferred, but useable.

I'd try something like this:
RewriteCond  %{REQUEST_URI}  !^/icons/
RewriteCond %{SERVER_NAME} ^www\.(.*)$ [NC]
RewriteCond  /var/www/${lowercase:%1} -d
RewriteRule  ^/(.*)$ /var/www/${lowercase:%1}/$1 [L]

Or you could just make symbolic links in the filesystem for the www
version.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message