2013-11-26 4 views
0

PHP 시작 스크립트 :Symfony 1.4 : 맞춤 도메인의 두 번째 앱?

  • 주요 응용 프로그램 :

    ~ec2-user/project/web/index.php 
    
  • 차 응용 프로그램 :

    ~ec2-user/project/web/api1.php 
    

아파치 설정 :

    0 /etc/httpd/conf/httpd.conf에서
  • 발췌 :

    <VirtualHost *:80> 
        ServerName example.com 
    
        DocumentRoot /home/ec2-user/project/web 
        DirectoryIndex index.html index.php 
        <Directory /home/ec2-user/project/web> 
         AllowOverride All 
         Allow from All 
        </Directory> 
    </VirtualHost> 
    
    <VirtualHost *:80> 
        ServerName 1.api.example.com # 1: version number 
    
        DocumentRoot /home/ec2-user/project/web 
        <Directory /home/ec2-user/project/web> 
         AllowOverride None 
        </Directory> 
    
        RewriteEngine On 
        RewriteRule ^(.*)$ /api1_dev.php [QSA,L] 
    </VirtualHost> 
    
  • ~ec2-user/project/web/.htaccess (전용 주 응용 프로그램에 적용해야합니다) : 예상

    Options +FollowSymLinks +ExecCGI 
    
    <IfModule mod_rewrite.c> 
        RewriteEngine On 
    
        # uncomment the following line, if you are having trouble 
        # getting no_script_name to work 
        #RewriteBase/
    
        # we skip all files with .something 
        #RewriteCond %{REQUEST_URI} \..+$ 
        #RewriteCond %{REQUEST_URI} !\.html$ 
        #RewriteRule .* - [L] 
    
        # we check if the .html version is here (caching) 
        RewriteRule ^$ index.html [QSA] 
        RewriteRule ^([^.]+)$ $1.html [QSA] 
        RewriteCond %{REQUEST_FILENAME} !-f 
    
        # no, so we redirect to our front web controller 
        RewriteRule ^(.*)$ index.php [QSA,L] 
    </IfModule> 
    

어떤 부하로 :

  • http://example.com : 홈 페이지

  • http://example.com/api1.php/foo/bar : 일부 JSON 데이터

무엇을하지 않습니다로드 :

  • http://1.app.example.com/foo/bar :

    404 | 찾을 수 없음 | sfError404Exception

    "/"(/) URL을 구문 분석 한 후 모듈 및/또는 동작이 비어 있습니다.

    [...]

나는 무엇을 놓치고? ~ EC2 사용자/프로젝트/웹/htaccess로에서

답변

0

:

RewriteRule ^(.*)$ /api1_dev.php [QSA,L] 

수신자 :

RewriteRule ^(.*)$ /api1_dev.php/$1 [QSA,L] 

의미가 있습니다.

RewriteRule ^(.*)$ index.php [QSA,L] 
0

,

의 주석이 RewriteBase이 /가이된다 :

나는 변화에 의해 작동하는 그것을 가지고
Options +FollowSymLinks +ExecCGI 

RewriteEngine On 

# uncomment the following line, if you are having trouble 
# getting no_script_name to work 
RewriteBase/

# we skip all files with .something 
#RewriteCond %{REQUEST_URI} \..+$ 
#RewriteCond %{REQUEST_URI} !\.html$ 
#RewriteRule .* - [L] 

# we check if the .html version is here (caching) 
RewriteRule ^$ index.html [QSA] 
RewriteRule ^([^.]+)$ $1.html [QSA] 
RewriteCond %{REQUEST_FILENAME} !-f 

# no, so we redirect to our front web controller 
RewriteRule ^(.*)$ index.php [QSA,L] 
+0

이 1.app.example.com''의 구성에'에 AllowOverride None'을 유의하시기 바랍니다 : 난 단지 $1 이 필요하지, 왜 example.com에 대한 .htaccess에서 궁금'.htaccess'은 아니다 해석하고, 그것을 바꾸는 것은 효과가 없다. – feklee