2013-06-19 33 views
2

我啓用mod_rewrite,但當我到主頁瀏覽器嘗試下載的東西。當我去app_dev.php瀏覽器顯示錯誤:如何正確進入主頁?

The requested URL /app_dev.php/ was not found on this server. 

我的區域設置主機被配置爲web目錄。

'的輸出應用程序/臺路由器:調試_welcome' 是:

[router] Route "_welcome" 
Name   _welcome 
Path  /
Host   ANY 
Scheme  ANY 
Method  ANY 
Class  Symfony\Component\Routing\Route 
Defaults  _controller: Acme\DemoBundle\Controller\WelcomeController::indexAction 
Requirements NO CUSTOM 
Options  compiler_class: Symfony\Component\Routing\RouteCompiler 
Path-Regex #^/$#s 

我的httpd-vhosts.conf:

<VirtualHost *:80> 
ServerAdmin [email protected] 
DocumentRoot "/var/www/symfony/hz.dev/web" 
ServerName hz.dev 
ServerAlias www.hz.dev 
ErrorLog "/var/log/apache2/hz.dev-error_log" 
CustomLog "/var/log/apache2/hz.dev-access_log" common 
</VirtualHost> 

我的網站/ .htaccsess

DirectoryIndex app.php 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule .? - [L] 
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ 
RewriteRule ^(.*) - [E=BASE:%1] 
RewriteRule .? %{ENV:BASE}app.php [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
<IfModule mod_alias.c>   
RedirectMatch 302 ^/$ /app.php/ 
</IfModule> 
</IfModule> 
+0

哪個路線設置爲'/''中的應用程序/配置/ routing.yml'?是執行'app/console router:debug'時顯示的'/'路由嗎? – nifr

+0

yes,app/console router:debug for'/'show '_welcome任何任何/' –

+0

app/console路由器的輸出是什麼:debug _welcome'? – nifr

回答

0

改爲使用.htaccess。這很簡單,我在開發過程中使用它。

<IfModule mod_rewrite.c> 
    RewriteEngine On 

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

然後,您應該能夠在http://example.com/訪問的Symfony不app_dev.php在URL