You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tim Bannister <is...@jellybaby.net> on 2007/07/28 12:37:26 UTC
Re: [users@httpd] help on apache mod_rewrite
On 28 Jul 2007, at 07:30, Marc Jacobs wrote:
> I need to create 1 virtual host that runs multiple sites (siteA.com) &
> siteB.com) located at different paths in the host.
…
> See the part of httpd.conf that relates to this virtual host:
>
> <VirtualHost *:80>
> DocumentRoot /var/www/vhosts/sites/httpdocs
> ServerName sites
> ServerAlias siteA.com www.siteA.com siteB.com www.SiteB.com
> RewriteEngine On
> # THIS IS NOT WORKING: this was intended to take you to the right
> path when you type siteA.com OR www.siteA.com
> RewriteCond %{HTTP_HOST} ^siteA\.com$ [NC,OR]
> RewriteCond %{HTTP_HOST} ^www\.siteA\.com$ [NC]
> RewriteRule ^/var/www/vhosts/sites/httpdocs(.*) /var/www/vhosts/
> sites/httpdocs/siteA$1
> # THIS IS NOT WORKING: this was intended take you to the right path
> when you type siteB.com OR www.siteB.com
> RewriteCond %{HTTP_HOST} ^siteB\.com$ [NC,OR]
> RewriteCond %{HTTP_HOST} ^www\.siteB\.com$ [NC]
> RewriteRule ^/var/www/vhosts/sites/httpdocs(.*) /var/www/vhosts/
> sites/httpdocs/siteB$1
> </VirtualHost>
Try this; it could be along the line of what you want:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^siteA\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.siteA\.com$ [NC]
RewriteRule ^/(.*)$ /var/www/vhosts/sites/httpdocs/siteA/$1
# and similarly for siteB
If you also use Alias directives, they might be affected by this.
Check that errors (eg 404) still look right with the configuration in
place.
--
Tim Bannister - +44 7980408788 - isoma@jellybaby.net
---------------------------------------------------------------------
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] help on apache mod_rewrite
Posted by Norman Peelman <np...@cfl.rr.com>.
Tim Bannister wrote:
> On 28 Jul 2007, at 07:30, Marc Jacobs wrote:
>
>> I need to create 1 virtual host that runs multiple sites (siteA.com) &
>> siteB.com) located at different paths in the host.
> …
>> See the part of httpd.conf that relates to this virtual host:
>>
>> <VirtualHost *:80>
>> DocumentRoot /var/www/vhosts/sites/httpdocs
>> ServerName sites
>> ServerAlias siteA.com www.siteA.com siteB.com www.SiteB.com
>> RewriteEngine On
>> # THIS IS NOT WORKING: this was intended to take you to the right
>> path when you type siteA.com OR www.siteA.com
>> RewriteCond %{HTTP_HOST} ^siteA\.com$ [NC,OR]
>> RewriteCond %{HTTP_HOST} ^www\.siteA\.com$ [NC]
>> RewriteRule ^/var/www/vhosts/sites/httpdocs(.*)
>> /var/www/vhosts/sites/httpdocs/siteA$1
>> # THIS IS NOT WORKING: this was intended take you to the right path
>> when you type siteB.com OR www.siteB.com
>> RewriteCond %{HTTP_HOST} ^siteB\.com$ [NC,OR]
>> RewriteCond %{HTTP_HOST} ^www\.siteB\.com$ [NC]
>> RewriteRule ^/var/www/vhosts/sites/httpdocs(.*)
>> /var/www/vhosts/sites/httpdocs/siteB$1
>> </VirtualHost>
>
> Try this; it could be along the line of what you want:
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^siteA\.com$ [NC,OR]
> RewriteCond %{HTTP_HOST} ^www\.siteA\.com$ [NC]
> RewriteRule ^/(.*)$ /var/www/vhosts/sites/httpdocs/siteA/$1
> # and similarly for siteB
>
> If you also use Alias directives, they might be affected by this.
> Check that errors (eg 404) still look right with the configuration in
> place.
>
> --Tim Bannister - +44 7980408788 - isoma@jellybaby.net
>
>
> ---------------------------------------------------------------------
> 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
>
I think rewrite* is overkill for this really. Although i've not
messed around with ServerAlias, I usually just duplicate the VH entries
with the appropriate ServerNames. I think it's easier to make mods to
each individual site that way.
Long way...
<virtualhost *>
ServerName siteA.com
...
</virtualhost *>
<virtualhost>
ServerName www.siteA.com
...
</virtualhost>
<virtualhost *>
ServerName siteB.com
...
</virtualhost *>
<virtualhost>
ServerName www.siteB.com
...
</virtualhost>
or simply try
Short way...
<virtualhost *>
ServerName siteA.com
ServerAlias www.siteA.com
...
</virtualhost>
<virtualhost *>
ServerName siteB.com
ServerAlias www.siteB.com
...
</virtualhost>
I'm still using the long way for now... no reason really other than i'm
too lazy to change it. :)
Norm
---------------------------------------------------------------------
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