You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tom Turrisi <to...@turrisi.co.uk> on 2006/01/26 12:13:59 UTC
[users@httpd] Mass configured virtual hosts and dynamic alias's
Hi,
I'm currently using apache 1.3 to serve virtual hosts dynamically using
the following config...
<VirtualHost removed:80>
ServerName removed
ErrorLog /var/log/error_log
CustomLog /var/log/sites_access_log ald
VirtualDocumentRoot /domains/%1.1/%1.2/%0/public_html
User nobody
Group sites
</VirtualHost>
This works fine but what i would like is to have an alias of /dshop go
to /domains/%1.1/%1.2/%0/shop for all the virtual hosts. Unfortunately
for me, the variables only work when using the VirtualDocumentRoot
directive and not the Alias directive.
I've looked around for a few hours, but i can't find an answer so i hope
someone here can help. I'll leave with a few more examples of what i'm
trying to achieve in case i haven't made my self clear enough.
Request for: http://foo.bar/dshop
Serves path: /domains/f/o/foo.bar/dshop
Request for: http://bar.foo/dshop/foo.htm
Serves path: /domains/b/a/bar.foo/dshop/foo.htm
Thanks
Tom Turrisi
---------------------------------------------------------------------
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] Mass configured virtual hosts and dynamic alias's
Posted by Tom Turrisi <to...@turrisi.co.uk>.
Joshua Slive wrote:
> On 1/26/06, Tom Turrisi <to...@turrisi.co.uk> wrote:
>
>>Thanks for you reply. It's put me in the right direction but i'm still
>>having a problem working out the correct regex for what i need to do.
>>
>>I don't know how to get the first and second characters of the domain
>>into the places where i have put <1> and <2> in the following config.
>>I also don't know how to strip www from the server_name if it's present.
>>I hope someone can be of help with this!
>
>
>> RewriteEngine On
>> RewriteMap lowercase int:tolower
>> RewriteRule ^/dshop/(.*)$
>>/domains/<1>/<2>/${lowercase:%{SERVER_NAME}}/shop/$1
>
>
> Something like
>
> RewriteCond ${lowercase:%{SERVER_NAME}} ^(www\.)?(.)(.)(.*)
> RewriteRule ^/dshop/(.*) /domains/%2/%3/%2%3%4/shop/$1
>
> 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
>
>
>
That has worked perfectly. Thank you so much!
Tom
---------------------------------------------------------------------
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] Mass configured virtual hosts and dynamic alias's
Posted by Joshua Slive <jo...@slive.ca>.
On 1/26/06, Tom Turrisi <to...@turrisi.co.uk> wrote:
> Thanks for you reply. It's put me in the right direction but i'm still
> having a problem working out the correct regex for what i need to do.
>
> I don't know how to get the first and second characters of the domain
> into the places where i have put <1> and <2> in the following config.
> I also don't know how to strip www from the server_name if it's present.
> I hope someone can be of help with this!
> RewriteEngine On
> RewriteMap lowercase int:tolower
> RewriteRule ^/dshop/(.*)$
> /domains/<1>/<2>/${lowercase:%{SERVER_NAME}}/shop/$1
Something like
RewriteCond ${lowercase:%{SERVER_NAME}} ^(www\.)?(.)(.)(.*)
RewriteRule ^/dshop/(.*) /domains/%2/%3/%2%3%4/shop/$1
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
Re: [users@httpd] Mass configured virtual hosts and dynamic alias's
Posted by Tom Turrisi <to...@turrisi.co.uk>.
Thanks for you reply. It's put me in the right direction but i'm still
having a problem working out the correct regex for what i need to do.
I don't know how to get the first and second characters of the domain
into the places where i have put <1> and <2> in the following config.
I also don't know how to strip www from the server_name if it's present.
I hope someone can be of help with this!
<VirtualHost removed:80>
ServerName removed
ErrorLog /var/log/error_log
CustomLog /var/log/sites_access_log ald
VirtualDocumentRoot /domains/%1.1/%1.2/%0/public_html
RewriteEngine On
RewriteMap lowercase int:tolower
RewriteRule ^/dshop/(.*)$
/domains/<1>/<2>/${lowercase:%{SERVER_NAME}}/shop/$1
User nobody
Group sites
</VirtualHost>
Tom
Joshua Slive wrote:
> On 1/26/06, Tom Turrisi <to...@turrisi.co.uk> wrote:
>
>
>>This works fine but what i would like is to have an alias of /dshop go
>>to /domains/%1.1/%1.2/%0/shop for all the virtual hosts. Unfortunately
>>for me, the variables only work when using the VirtualDocumentRoot
>>directive and not the Alias directive.
>
>
> Right. If you want to do this type of interpolation on alias-type
> things, you'll need to throw out mod_vhost_alias and use mod_rewrite:
> http://httpd.apache.org/docs/1.3/vhosts/mass.html#simple.rewrite
>
> 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
>
>
>
---------------------------------------------------------------------
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] Mass configured virtual hosts and dynamic alias's
Posted by Joshua Slive <jo...@slive.ca>.
On 1/26/06, Tom Turrisi <to...@turrisi.co.uk> wrote:
>
> This works fine but what i would like is to have an alias of /dshop go
> to /domains/%1.1/%1.2/%0/shop for all the virtual hosts. Unfortunately
> for me, the variables only work when using the VirtualDocumentRoot
> directive and not the Alias directive.
Right. If you want to do this type of interpolation on alias-type
things, you'll need to throw out mod_vhost_alias and use mod_rewrite:
http://httpd.apache.org/docs/1.3/vhosts/mass.html#simple.rewrite
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