2012-01-13 130 views
2

在我的本地机器上,我创建的symfony项目非常完美。Symfony 404错误

我已经在我的测试服务器上安装了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. 

下面是一些例子:

在我的本地机器上使用甲基苯丙胺,我用下面的网址正常工作:

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

后,我已经上传的一切,如果我去测试服务器URL:

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

我使用/ sf图像和样式获得“项目成功”页面。

如果我尝试

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

我得到的404错误,就像在页面不存在,这让我THIK smfony不知道的前端模块。

任何帮助?

回答

7

你需要做两件事情:

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

2)仔细检查文档根目录中的.htaccess文件,确保它指向您的app.php。沿着线的东西:

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

感谢。我没有尝试最明显的网址。我输入http://my.url.com:8090/index.php/mymodule,它工作!现在我有一个内部服务器错误,但嘿...它的进展。 – 2012-01-13 23:29:37

+0

不客气。乐意效劳。 – webbiedave 2012-01-13 23:35:05

3

我曾经有过这样的问题太多,请大家看看我的配置,并尝试出来

我的.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的/网站可用我的 “的symfony” 条目中:

<VirtualHost 127.0.1.15> 
ServerAdmin [email protected] 
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>