2014-03-02 33 views
0

我想要做一些URL重寫與htacesshtacess重寫除了一個參數

http://www.mydomain.com/article.php?post_id=123&title=2014-03-02-today-s-trends 
=> 
http://www.mydomain.com/article/123/2014-03-02-today-s-trends 

但一些特殊的規則。如果一些文章點擊rss或社交分享。我想:

http://www.mydomain.com/article.php?post_id=123&title=2014-03-02-today-s-trends&source=rss 
=> 
http://www.mydomain.com/article/123/2014-03-02-today-s-trends?source=rss 

我重寫代碼在這裏

RewriteRule ^article/(\d+)/(.*)\?source=(.*)?$ article.php?post_id=$1&title=$2&source=$3 

,但得到500錯誤。如何以正確的方式做到這一點?謝謝。

回答

1

如果source=rss位於URL上,您可以使用QSA標誌,以便它將追加查詢字符串。

不知道你的ogininal重寫是如何,但你可以試試這個。它應該有或無source=rss

RewriteRule ^article/(.+)/(.+)$ article.php?post_id=$1&title=$2 [QSA,L] 

然後在你的代碼,你可以檢查在$ _GET的source關鍵。