当我这样访问我的网站时:
example.com/
或
example.com/app_dev.php
工作正常。
但是当我尝试去另一条路线时,如
example.com/api/route/option
我收到错误404,但是当我去
时example.com/app_dev.php/api/route/option
这很好。
这是我的.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^app_dev.php - [L]
RewriteRule ^app.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ app.php [QSA,L]
RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
这是我的虚拟主机
<VirtualHost *:80>
ServerName example.com
ServerAdmin my_mail
DocumentRoot /var/www/html/example/web/
DirectoryIndex app_dev.php
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
有个主意吗?
谢谢!
答案 0 :(得分:1)
您的虚拟主机文件不会启用覆盖,这意味着您的.htaccess
文件正在读取。尝试将其添加到虚拟主机文件中:
<Directory /var/www/html/example/web/>
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
您可能还想查看此处记录的其他设置选项:http://symfony.com/doc/current/setup/web_server_configuration.html