2012-01-13 134 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>