symfony apache 配置错误,控制器未被调用

发布于 2024-12-25 18:33:38 字数 1081 浏览 2 评论 0原文

我按照入门教程中所述配置了我的/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埖埖迣鎅 2025-01-01 18:33:38

如果 app.php/poster 正常工作,这可能取决于 settings.yml 中的设置(猜测您正在后端使用安全模式):

prod:
  .settings:
    no_script_name:         false

如果这是问题,您必须更改为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):

prod:
  .settings:
    no_script_name:         false

If this is the problem, you have to change to true the no_script_name parameter.

I hope this can help you.

汹涌人海 2025-01-01 18:33:38

听起来 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文