2014-04-02 19 views
2

我想將帖子ID移動到URL中的最後一個位置。就像這樣:RewriteRule:在URL中移動ID文章

http://www.mysite.com/news/123-post.html 

http://www.mysite.com/news/post-123.html 

原始的htaccess

RewriteRule ^([^.]+)/([0-9]+)-(.*).html$ index.php?newsid=$2&seourl=$3&seocat=$1 [L] 

我改變

RewriteRule ^([^.]+)/(.*)-([0-9]+).html$ index.php?newsid=$2&seourl=$3&seocat=$1 [L] 

,並粘貼在瀏覽器新的URL http://www.mysite.com/news/post-123.html但它不工作

+0

你能告訴你完成,你可以優化通過確保seourl不包含任何斜槓(/)您的規則。 htaccess文件? – anubhava

回答

0

已轉換news idseo url參數。你必須在你的規則中做同樣的事情。

這條規則(新一)

RewriteRule ^([^.]+)/(.*)-([0-9]+).html$ index.php?newsid=$2&seourl=$3&seocat=$1 [L] 

應該是這樣的

RewriteRule ^([^.]+)/(.*)-([0-9]+).html$ index.php?newsid=$3&seourl=$2&seocat=$1 [L] 

$2現已成seourl$3現在是爲newsid。否則,你會遇到問題。

另外,如果你希望它是隻在同一個文件夾,而不是一個entier路徑

+1

謝謝Justin – NuLL