【发布时间】:2013-11-26 21:17:29
【问题描述】:
PHP 启动脚本:
-
主要应用:
~ec2-user/project/web/index.php -
辅助应用:
~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> -
~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 “/” (/) 后的空模块和/或操作。
[…]
我错过了什么?
【问题讨论】:
标签: mod-rewrite routing symfony1 apache2 symfony-1.4