Available for the site (apache) and httpd.conf for WAMP - create XXXXX.domain.com automatically

I currently have this in the httpd.conf file in WAMP:

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
    ServerAlias *.dev.co.uk
    UseCanonicalName Off
    VirtualDocumentRoot D:/wamp/www/%1/httpdocs
</VirtualHost>

I created the directory "foo.bar" and then tried http://foo.bar.dev.co.uk and I get the following:

Not found

The requested URL / not found this server.

I want this setting to work on my local apache server as well as on my wamp server (I think the syntax is a little different). If I need to provide more information, leave a comment and I will update.

+3
source share
2 answers

I have never used VirtualDocumentRoot, but, seeing that you are not receiving any answers, I will give it away.

docs Interpolation Directory Name, , %1, "foo" http://foo.bar.dev.co.uk.

"foo.bar", :

VirtualDocumentRoot D:/wamp/www/%1.0.%2.0/httpdocs

%1 "foo", %2 "bar". .0, , foo bar ( . ).

, , , Apache . , .

Update

:

" foo.bar.dev.co.uk , , foo.dev.co.uk , ?"

.

- %0 , .

VirtualDocumentRoot D:/wamp/www/%0/httpdocs

D:/wamp/www/foo.bar.dev.co.uk/httpdocs D:/wamp/www/foo.dev.co.uk/httpdocs.

, . , :

  • "foo.dev.co.uk"
  • "bar.dev.co.uk"
  • "foo.bar.dev.co.uk"
  • .. "X.Y.dev.co.uk"

"foo" "bar" VirtualHost .

<VirtualHost 127.0.0.1>
    ServerAlias foo.dev.co.uk 
    ServerAlias bar.dev.co.uk
    UseCanonicalName Off
    VirtualDocumentRoot D:/wamp/www/%1/httpdocs
</VirtualHost>

<VirtualHost 127.0.0.1>
    ServerAlias *.dev.co.uk
    UseCanonicalName Off
    VirtualDocumentRoot D:/wamp/www/%1.0.%2.0/httpdocs
</VirtualHost>
+2

, :

1) localhost ip
, , 127.0.0.1. , , hosts Windows. C:\Windows\System32\drivers\etc\hosts:

127.0.0.1 foo.bar.dev.co.uk

, , . this.

2) :
, http, , httpd.conf( ):

Listen 80

3) :
NameVirtualHost XXX.XXX.XXX.XXX, , NameVirtualHost. , .

4) :
, , Linux, , Windows , . - . " Interpolation Directory Name , . Pls .

5) :
, vhost wamp. vhost, , URL-, - apache:

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common 

6) ...
: .

, , .

0

All Articles