[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Apache2 & mod_rewrite



Angelo Bertolli wrote:

Marco wrote:

Angelo Bertolli ha scritto:

<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAlias pop.domain.com
...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^pop\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 <http://descartes.homelinux.org/$1> [R=301,L]
</VirtualHost>




Hi,
with this settings the web site is opened, but the URL doesn't come rewritten. :-( Does not exist however a common rule for all "CNAME" without to make one line for the POP one for the SMTP etc...


Sorry, the RewriteRule should be
RewriteRule ^(.*)$ http://www.domain.com/$1  [R=301,L]

Maybe try this one:

<VirtualHost *:80>
ServerName domain.com
ServerAlias *.domain.com
...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
|RewriteCond %{HTTP_HOST}!^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
|RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</VirtualHost>

|I'm not sure about if this part will work:
||^([^.]+)

Of course get rid of all the |






Reply to: