Mod rewrite Symfony 1.4:自定义域上的第二个应用程序?

Mod rewrite Symfony 1.4:自定义域上的第二个应用程序?,mod-rewrite,routing,symfony1,apache2,symfony-1.4,Mod Rewrite,Routing,Symfony1,Apache2,Symfony 1.4,PHP启动脚本: 主要应用程序: ~ec2-user/project/web/index.php 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 /

PHP启动脚本:

  • 主要应用程序:

    ~ec2-user/project/web/index.php
    
    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>
    
  • 辅助应用程序:

    ~ec2-user/project/web/api1.php
    
Apache配置:

  • 摘自
    /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>
    
预期的负载是什么:

  • http://example.com
    :主页

  • http://example.com/api1.php/foo/bar
    :一些JSON数据

未加载的内容:

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

    404 |未找到| SFERROR404异常

    解析URL“/”(/)后的空模块和/或操作

    [……]


我缺少什么?

在~ec2 user/project/web/.htaccess中

取消对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]

我通过改变以下方式使其发挥作用:

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

有道理。我只是想知道为什么在
example.com
.htaccess
中,
$1
没有必要:

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

请注意,
1.app.example.com
.htaccess
的配置中的
AllowOverride None
,不会被解释,因此更改它没有任何效果。
RewriteRule ^(.*)$ index.php [QSA,L]