문제

I want to make some url rewrite with htaccess,

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

but some special rule. if some article click from rss or social share. I want to:

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

my rewrite code here

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

but get 500 error. How to do it in a right way?

도움이 되었습니까?

해결책

You can just use the QSA flag so that it will append the query string with it if source=rss is on the URL.

Not sure how your ogininal rewrite is but you can try this. It should work with or without source=rss

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

Then in your code you can check for the source key in the $_GET.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top