【问题标题】:Symfony 404 errorsSymfony 404 错误
【发布时间】:2012-01-13 17:35:40
【问题描述】:

在我的本地机器上,我创建的 symfony 项目运行良好。

我已经在我的测试服务器上安装了 symfony,它工作正常。当我在浏览器中访问 URL 时,我会看到“Symfony Project Created”页面。我运行了 check_configuration.php 并检查了所有内容。

我遇到的问题是:我已经创建了我的数据库并上传了表格数据。我已使用 FTP 将文件从本地计算机上传到服务器。当我尝试访问我创建的模块时,它会抛出 404 错误:

找不到

The requested URL /mymodule was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

这里有一些例子:

在使用 MAMP 的本地计算机上,我使用以下 URL 可以正常工作:

http://localhost:8080/frontend_dev.php/mymodule

上传所有内容后,如果我转到测试服务器 URL:

http://my.url.com:8090/

我得到带有 /sf 图像和样式的“项目成功”页面。

但是如果我尝试

http://my.url.com:8090/mymodule

我收到 404 错误,好像页面不存在,这让我觉得 smfony 不知道前端模块。

有什么帮助吗?

【问题讨论】:

    标签: php mysql symfony1 doctrine


    【解决方案1】:

    你需要做两件事:

    1) 确保在 Apache 中启用了 mod_rewrite。

    2) 仔细检查文档根目录中的.htaccess 文件,确保它指向您的app.php。大致如下:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
    

    【讨论】:

    • 谢谢。我没有尝试最明显的网址。我输入了my.url.com:8090/index.php/mymodule,它成功了!现在我有一个内部服务器错误,但是嘿......它的进展。
    【解决方案2】:

    我以前也有这个问题,请看我的配置试试看

    在我的 .htaccess 中:

    大家好,我也遇到了这个问题。似乎“股票” .htaccess 是问题所在。我已经在我的环境中解决了这个问题,这是我的 .htaccess 和注释:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
        RewriteRule ^(.*) - [E=BASE:%1]
        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]    ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
        RewriteCond %{REQUEST_FILENAME} -f
        RewriteRule .? - [L]
        RewriteRule .? %{ENV:BASE}/app_dev.php [L]        ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        <IfModule mod_alias.c>
            # When mod_rewrite is not available, we instruct a temporary redirect of
            # the startpage to the front controller explicitly so that the website
            # and the generated links can still be used.
            RedirectMatch 302 ^/$ /app.php/
            # RedirectTemp cannot be used instead
        </IfModule>
    </IfModule>
    

    在 /etc/apache2/sites-available 中的“symfony”条目中:

    <VirtualHost 127.0.1.15>
    ServerAdmin webmaster@localhost
    ServerName symfony
    DocumentRoot /var/www/Symfony/web
    DirectoryIndex app.php
    <Directory /var/www/Symfony/web>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多