2011-03-10 86 views
1

我是新來的Apache的mod_rewrite,我有一個問題...的.htaccess問題

如果我使用的網址:mysite.com/nl/或mysite.com/fr/我越來越重定向到正確的頁面,當用戶輸入url mysite.com我重定向我的用戶到NL語言,但問題是在地址欄url保持mysite.com,我希望它是mysite.com/nl

這是我的htaccess文件:

RewriteEngine on 
DirectoryIndex index.php 
RewriteBase/

# Rewrite voor taal en pagina 
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ $1/$2 [R] 
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?tl=$1&pg=$2 [L] 

#rewrite voor taal 
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ $1 [R] 
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?tl=$1 [L] 

我的文件夾結構是:

[nl] 
    index.php 
    contact.php 
[fr] 
    index.php 
    contact.php 
index.php 

index.php文件的內容(根目錄):

<? 
switch ($_REQUEST['tl']) 
    { 

     case 'nl': 

      switch ($_REQUEST['pg']) 
      { 
       case 'contact': 
        include_once("nl/contact.php"); 
       break; 

       default: 
        include_once("nl/index.php"); 
       break; 
      } 


     break; 

     case 'fr': 
       include_once("fr/index.php"); 
     break; 

     default: 
      include_once("nl/index.php"); 
     break; 
    } 
?> 

所以,當一個用戶進入mysite.com它顯示了NL目錄在瀏覽器中的index.php,但網址地址保持mysite.com但應mysite.com/nl/

,因爲我已經在這個重寫規則我一直停留在這幾個小時零經驗...

在此先感謝,

腹魚

回答

1

而不是使用include_once的請嘗試使用header('Location: /nl/page.php')header('Location: /fr/page.php');