2014-09-29 127 views
0

我使用htaccess的重寫我的網址所以這裏就是我:htaccess的重寫規則URL的

RewriteRule ^([^-]+),([a-z0-9._.-]+),([^-]+) index.php?go=$1&lang=$2 [L] 

和代碼PHP:

function rewrite_seo($id, $title, $langs) { 
    global $core; 
    if($core->getSettings('seof')) { 
     $result = $id.','.$langs.','.changeSigns($title).''; 
    } else $result = '?go='.$id.'&lang='.$langs; 
    return $result; 
} 

我的網址是這樣的:

http://localhost/script/12,en,home 

但想看起來像這樣:

http://localhost/script/en/home,12 

如何修改此代碼?

回答

0

本地主機/腳本/ 12,EN,回家 本地主機/腳本/ EN /家,12

難道ü嘗試修改4行?

端起: $result = $langs.'/'.changeSigns($title).','.$id;

請看看到PHP.net網頁http://php.net/manual/de/internals2.opcodes.concat.php

+0

是的,但我有一個404錯誤,因爲我不得不修改httacces,但我不能。 – johny321 2014-09-29 13:29:44

+0

所以,你應該有或者嘗試改變:h新規則。 – erm3nda 2014-09-29 19:57:10

0

你必須改變用PHP編寫的鏈接在前面的回答中指出:

$result = $langs.'/'.changeSigns($title).','.$id; 

然後在你的htaccess中改變匹配規則:

RewriteRule ^([a-z0-9._.-]+)\/([^-]+),([^-]+) index.php?go=$2&lang=$1 [L] 

更妙的是,你可以做更具體的捕獲正則表達式,所以它會更容易閱讀和理解:

RewriteRule ^([a-z]+)\/([0-9]+),([^-]+) index.php?go=$2&lang=$1 [L]