symfony apache 配置错误,控制器未被调用
我按照入门
教程中所述配置了我的/etc/apache/httpd.conf
:
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/var/www/innobo/web"
DirectoryIndex index.php
<Directory "/var/www/innobo/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /var/www/symfony/data/web/sf
<Directory "/var/www/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
Alias /uploads /var/www/innobo/web/uploads
<Directory "/var/www/innobo/web/uploads">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
我在网络浏览器中打开localhost:8080
,它工作正常。但是当我尝试打开任何其他内容(例如 localhost:8080/poster
)时,它会抛出 404
。这不是 symfony 重定向的 404,而是 apache 生成的默认 404!这意味着 apache 没有将请求发送到我的控制器,即 /var/www/innobo/web/index.php
。我在另一台电脑上尝试了同样的操作,效果很好。请求到达控制器,一切都按预期进行。错在哪里呢?
I configured my /etc/apache/httpd.conf
as said in the getting started
tutorial :
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/var/www/innobo/web"
DirectoryIndex index.php
<Directory "/var/www/innobo/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /var/www/symfony/data/web/sf
<Directory "/var/www/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
Alias /uploads /var/www/innobo/web/uploads
<Directory "/var/www/innobo/web/uploads">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
I open localhost:8080
in web browser, it works fine. but when I try to open anything else like localhost:8080/poster
, it throws a 404
. And that's not a 404 redirected by symfony, it's the default one generated by apache! That means apache is not sending the request to my controller i.e. /var/www/innobo/web/index.php
. I tried the same on another computer, it works fine. there the request reaches controller and everything works as expected. Where can the fault lie?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 app.php/poster 正常工作,这可能取决于
settings.yml
中的设置(猜测您正在后端使用安全模式):如果这是问题,您必须更改为
true
no_script_name
参数。我希望这可以帮助你。
If app.php/poster is working, this could depend by a setting in
settings.yml
(guessing you are working with secure mode in backend side):If this is the problem, you have to change to
true
theno_script_name
parameter.I hope this can help you.
听起来 mod_rewrite 没有打开/工作。尝试
localhost:8080/app.php/poster
您还应该运行 symfony 检查脚本。默认情况下,您可以在 /web/config.php 中找到它,因此您应该可以通过在浏览器中输入
localhost:8080/config.php
来访问它It sounds like mod_rewrite isn't on/working. try
localhost:8080/app.php/poster
You should also run the symfony check script. By default, you can find it it /web/config.php, so you should be able to access it by putting
localhost:8080/config.php
in you browser