Forum Moderators: phranque
I have a little problem regarding the www.
Here's what I have so far THAT WORKS(Partially)
###
# Map File
###
domain1.com/clients/72504
domain2.com/clients/72505
domain3.com/clients/72506
...
###
# httpd.conf
###
UseCanonicalName Off
RewriteEngine On
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/www/conf/vhosts.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1 [L]
This setup works fine when the URL is example1.com. However, it does NOT work with www.example1.com.
I know I could simply add another entry with the www. in my map file like:
domain1.com/clients/72504
www.domain1.com/clients/72504
However, this is unnecessary if I can have apache remove the www automatically.
How can I remove the www portion of the URL in order to match my map file?
Thanx in advance,
Gadnium
Your solution works:
RewriteCond ${lowercase:%{SERVER_NAME}} ^(www\.)?(.+)$
RewriteCond ${vhost:%2} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1 [L]
As I did not know the %1 was dropped:
RewriteCond ${lowercase:%{SERVER_NAME}} ^(www\.)?(.+)$
RewriteCond ${vhost:%2} ^(/.*)$
RewriteRule ^/(.*)$ %2/$1 [L]
Thank You.
Gadnium