2014-09-29 126 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]