【问题标题】:Symfony 1.4 Error 400 on the home page in prod env (not in dev env)产品环境中主页上的 Symfony 1.4 错误 400(不在开发环境中)
【发布时间】:2011-01-20 16:12:14
【问题描述】:

我已经在我的电脑上测试了一个应用程序,一切正常(我只通过 frontend_dev.php 页面使用了开发环境)。

当我在测试服务器上部署此应用程序时,出现以下错误 400 Bad Request:

错误请求

您的浏览器发送了此服务器无法理解的请求。

我使用正常 URL 访问了该网站。 我正在使用 symfony 1.4 和学说(不涉及其他插件),wamp 2(php 5.3,apache 2.0.59)。

如果我尝试使用开发环境访问应用程序,它可以工作。

【问题讨论】:

    标签: symfony1 symfony-1.4


    【解决方案1】:

    尝试检查您的应用程序setting.yml 文件上的no_script 属性。如果应该设置为 False,请清除缓存并重试

    【讨论】:

      【解决方案2】:

      非常感谢桂曼。你让我找到了答案。

      no_script_name 属性不是问题的根源。相反,我在 web 目录中有我的.htaccess,它生成得很糟糕(我发誓我以前没有编辑过这个文件)。下面是 symfony 生成的文件(代码一中粗体属性不起作用,看最后一行):

      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>
      

      这是更新后的(再次看最后一行):

      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 ^(.*)$ **/myApp/index.php** [QSA,L]
      </IfModule>
      

      我不知道发生了什么,但我会在 symfony 网站上查看是否有类似问题。

      【讨论】:

      • 嗯,这将是我的第二种方法:P,很高兴知道您可以自己解决这个问题!干杯
      • 如果 *no_script_name * 不是问题,为什么你接受另一个答案,然后说这是问题?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 1970-01-01
      • 2014-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多