You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chris tunnell <xi...@yahoo.com> on 2004/06/11 00:39:26 UTC

[users@httpd] Mod_rewrite - Removing www on dynamic domain names

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.

Thanks in advance for your responses!


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

---------------------------------------------------------------------
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


Re: [users@httpd] Mod_rewrite - Removing www on dynamic domain names

Posted by Joshua Slive <jo...@slive.ca>.
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