2013-02-13 3 views
0

내가 ... 하위 디렉토리가 함께 설치에이 같은 주소에 내 프로젝트를 실행해야 URL에 가상 호스트를 관리 할 수 ​​없습니다 :아파치 가상 호스트 URI 일세

http://www.projects.loc/project1/ 이에 설치를 모방한다을 나는 그것이 www.projects.loc/project1/

로 돌아갑니다 있도록 리디렉션 '/'로 조정해야

http://www.someServer.com/projects/project1/

같은 웹 서버는 어디 주소가있을 것 HOSTS.TXT에서 내가 가진 :

127.0.0.1  www.projects.loc 

가상 호스트가 활성화되고, 아파치 - vhosts.conf은 다음과 같다 : 나는 무엇을 놓치고

NameVirtualHost *:80 

<VirtualHost *:80> 
    DocumentRoot "D:/Projects/Project1/public/"   
    ServerName www.projects.loc/project1/ 
</VirtualHost> 

?

편집 : htaccess로는 다음과 같습니다

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php [NC,L] 

응용 프로그램이 깨끗한 도메인에서 정상적으로 실행됩니다,하지만 난 domain.com/some_dir/

에 실행에 config (설정)을 관리 할 수 ​​없습니다

편집 :
이 문제를 해결했습니다.

NameVirtualHost *:80 

    <Directory "D:/Projects"> 
     allow from all 
    </Directory> 

    <VirtualHost *:80> 
     DocumentRoot "D:/Projects"  
     ServerName www.projects.loc/ 

     Alies /project1 /Project1/public/ 
    </VirtualHost> 

참고 :이 생산 evironment에 대한 자세한 내용에 대한 @ M-Z 만 개발 환경에 대한 좋은 최소한의 구성,
검사 허용 ansler입니다.

+1

다시 쓰기 당신은 시도 무엇입니까? – 244an

답변

1

아마도 이미 해당 질문을 해결했습니다. 어쨌든, 오늘 비슷한 일을 찾고 있었다, 그러므로 나는 문서화 여기에 솔루션 : 당신은 그냥 "프로젝트 1"이라는 하나 개의 프로젝트를 가지고있는 경우 서버 이름

ServerName www.projects.loc/project1/

에 슬래시를 쓰고 싶지 않아

, 당신은 쉽게 "해당 ServerPath"함께 일을 얻을 수 있습니다, 당신의 가상 호스트 설정은 다음과 같이 표시됩니다 :

<VirtualHost *:80> 
ServerName projects.loc 
ServerAlias www.projects.loc 
ServerPath /project1/ 
DocumentRoot /PATH/public_html 
ErrorLog /PATH/error_log 
CustomLog /PATH/access_log combined 
DirectoryIndex index.html index.htm index.php index.php4 index.php5 
<Directory /PATH/public_html> 
Options -Indexes +IncludesNOEXEC +FollowSymLinks 
allow from all 
</Directory> 
</VirtualHost> 

당신이 프로젝트 1을/projects.loc하는 디렉토리를 마운트 할 수있는 ServerPath를 통해

어쨌든, 가정 projects.loc/project1, projects.loc/project2 등등에 바인딩하려는 여러 프로젝트 (project1, project2)가 "별칭"을 사용합니다. 귀하의 가상 호스트 설정 파일은 다음과 같아야합니다

<VirtualHost *:80> 
ServerName projects.loc 
ServerAlias www.projects.loc 
DocumentRoot /PATH/public_html 
ErrorLog /PATH/error_log 
CustomLog /PATH/access_log combined 
DirectoryIndex index.html index.htm index.php index.php4 index.php5 
<Directory /PATH/public_html> 
Options -Indexes +IncludesNOEXEC +FollowSymLinks 
allow from all 
</Directory> 

Alias /project1 "/PATH/public_html/project1" 
<Directory "/PATH/public_html/project1"> 
DirectoryIndex index.html index.htm index.php index.php4 index.php5 
Options -Indexes +IncludesNOEXEC +FollowSymLinks 
allow from all 
</Directory> 

Alias /project2 "/PATH/public_html/project2" 
<Directory "/PATH/public_html/project2"> 
DirectoryIndex index.html index.htm index.php index.php4 index.php5 
Options -Indexes +IncludesNOEXEC +FollowSymLinks 
allow from all 
</Directory> 
</VirtualHost> 

다음, projects.loc/프로젝트 1에서 사용할 수있는 폴더/PATH/public_html을/프로젝트 1에 누워 귀하의 응용 프로그램 폴더/PATH/public_html을 부설 응용 프로그램/project2는 projects.loc/project2에서 사용할 수 있습니다.

다른 응용 프로그램에 다른 하위 도메인을 사용하고 싶습니다. 이렇게하면 모든 하위 도메인 호스트에 대해 고유 한 구성 파일을 가질 수 있으므로 오류 및 액세스 로그 처리가 쉬워집니다.별칭을 사용하면 애플리케이션별로 오류 및 액세스 로그를 구성하려는 경우 오류 및 액세스 로그를 다르게 구성하는 것이 더 어려워집니다.

추가 읽기 :
에 관한 별칭 : 해당 ServerPath에 관한 http://httpd.apache.org/docs/current/mod/mod_alias.html
는 : http://httpd.apache.org/docs/2.2/vhosts/examples.html#serverpath

+0

나는 이것을 지금 풀었고 나는 당신의 ansler를 리뷰 할 때 .. 그것은 정확하지만 상세한 것은 .. 그래서 처음에는 알지 못했다. :) –

관련 문제