2013-04-22 64 views
1

使用我當前的配置,每次鍵入something.com時,都會顯示app_dev.php,因爲我當前的重寫規則是正確的。但我要的是,如果用戶鍵入www.something.com它會自動引導到www.something.com/home如何將DirectoryIndex設爲控制器路徑?

注:「家」是我包的下一個路由

這是我目前的配置

<VirtualHost *:80> 
    # Admin email, Server Name (domain name), and any aliases 
    ServerAdmin [email protected] 
    ServerName www.something.com 

    # Index file and Document Root (where the public files are located) 
# DirectoryIndex home # I have already tried this, nothing happens 
    DocumentRoot /home/user/public/something.com/web/symfony/web 

    # Log file locations 
    LogLevel warn 
    ErrorLog /home/user/public/something.com/log/error.log 
    CustomLog /home/user/public/something.com/log/access.log combined 
</VirtualHost> 

內的Symfony /網站的.htaccess

<IfModule mod_rewrite.c> 
    RewriteRule ^$ app.php/home [L] 

    Options +FollowSymlinks 
    RewriteEngine On 

    # Explicitly disable rewriting for front controllers 
    RewriteRule ^app_dev.php - [L] 
    RewriteRule ^app.php - [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 

    # Change below before deploying to production 
    RewriteRule ^(.*)$ app.php [QSA,L] 
    #RewriteRule ^(.*)$ app_dev.php [QSA,L] 

</IfModule> 

實際的網址必須是www.something.com/app.php/home(目前的規則隱藏了app.php)

編輯:更新了給出答案的.htaccess基礎。但仍然沒有工作

回答

0

頂部

RewriteRule ^$ home [L] 

此插入一個RewriteRule會重定向到/home,如果你想在客戶端看到這個URL,你必須添加一個R標誌的規則。

+0

返回/在此服務器中的家。其實我的原始網址是www.something.com/app.php。我目前的配置隱藏app.php,我需要在每個頁面中都有。總之,我應該有www.something.com/app.php/home當我嘗試了你的建議。它刪除了app.php – Teffi 2013-04-22 06:14:54

+0

@Saber請參閱更新的答案。 – 2013-04-22 06:29:46

+0

仍然無法使用。 404找不到。這裏是實際的鏈接 - > cloud-pod.net返回404,但cloud-pod.net/home返回頁面。 – Teffi 2013-04-23 05:40:08