2014-04-26 2 views
3

다른 게시물을 통해 읽었지만 질문에 대한 답을 얻지 못했습니다. 와일드 카드 도메인의 와일드 카드 도메인을 가질 수 있습니까 (예 : 하위 도메인이든 하위 하위 도메인이든) : foo.example.local. 이미 example.local이 작동하지만 foo.example.local을/example 폴더 내의/sub/foo 폴더에서 가져 오는 방법을 알아낼 수 없습니다. 이 순간에 내 설정 (아파치 - vhost.conf) :Xampp Virtualhost : 와일드 카드 도메인 및 하위 도메인

NameVirtualHost *:80 
<VirtualHost *:80> 
    DocumentRoot "C:/xampp/www" 
    ServerName localhost 
    ServerAlias localhost 
</VirtualHost> 
<Virtualhost *:80> 
VirtualDocumentRoot "C:/xampp/www/%-2" 
    ServerName domain.local 
    ServerAlias *.local 
    <Directory "C:/xampp/www/*"> 
     Options Indexes FollowSymLinks Includes ExecCGI 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
     Require all granted 
    </Directory> 
</Virtualhost> 
<Virtualhost *:80> 
    VirtualDocumentRoot "C:/xampp/www/%-2/sub/%-3" 
    ServerName sub.domain.local 
    ServerAlias *.*.local 
    <Directory "C:/xampp/www/*/sub/*"> 
     Options Indexes FollowSymLinks Includes ExecCGI 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
     Require all granted  
    </Directory> 
</Virtualhost> 

어떤 일이 발생하면 foo.example.local는 단순히 예/부/foo는 폴더에 예제 폴더로 이동하지 것입니다 내가 원하는 걸.

아, 그리고 난 이미 활성화 :

  • 127.0.0.1 example.local는
  • 127.0.0.1 foo.example.local
  • : httpd.conf를 내 LoadModule vhost_alias_module modules/mod_vhost_alias.so

    호스트 파일은 두 줄이 포함

답변

3

와일드 카드를 통해 하위 도메인 기능을 추가하기 위해 알아 냈습니다. * .domain.local에서 *로 이전에 두 번째 별표를 사용해야했습니다. * 다음과 같이 .local의 그래서 최종 결과는 다음과 같습니다

<VirtualHost *:80> 
    DocumentRoot "C:/xampp/www" 
    ServerName localhost 
    ServerAlias localhost 
</VirtualHost> 
<Virtualhost *:80> 
    VirtualDocumentRoot "C:/xampp/www/%-2/sub/%-3" 
    ServerName sub.domain.local 
    ServerAlias *.*.local 
    <Directory "C:/xampp/www/*/sub/*"> 
     Options Indexes FollowSymLinks Includes ExecCGI 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
     Require all granted  
    </Directory> 
</Virtualhost> 
<Virtualhost *:80> 
    VirtualDocumentRoot "C:/xampp/www/%-2" 
    ServerName domain.local 
    ServerAlias *.local 
    <Directory "C:/xampp/www/*"> 
     Options Indexes FollowSymLinks Includes ExecCGI 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
     Require all granted 
    </Directory> 
</Virtualhost> 

을 그리고 중요한 부분은 이것이다 :

VirtualDocumentRoot "C:/xampp/www/%-2/sub/%-3" 
ServerName sub.domain.local 
ServerAlias *.*.local 
<Directory "C:/xampp/www/*/sub/*"> 

간단한 수정 주와 동일한 폴더 내에 하위 도메인을 만들 쉽게 만들기 도메인. 단일 프로젝트 폴더 내에 여러 도메인을 쉽게 만들 수 있습니다.

관련 문제