1

I am using ISAPI rewrite to rewrite a news feed to our web site. The problem I have is that the rewrite rule does not account for optional parameters that may be passed for google tracking.

A typical link is a follows:

http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%EF%BF%BDvery-important%EF%BF%BD.html

The rewrite rule that covers this is:

Rewriterule ^/motorcycle_news/categories/(.*?)/news_(\d+)_(.*)\.html$ /newsItem.asp?cat=$1&cpID=$2&page=$3 [NC]

Obviously the issue lies in the use of the $ after the .html part of the rewrite rule. The question is how can I change this so that a combination of possible google parameters can be added to the url without causing the link to break on the server?

parameters like:

?utm_source=dlvr.it&utm_medium=twitter

Any clues are greatly welcomed and appreciated.

4

1 回答 1

0

请尝试按如下方式修复您的规则:

RewriteCond %{QUERY_STRING} ^(utm_source=.*&utm_medium=.*)?$ [NC]
Rewriterule ^/motorcycle_news/categories/([^/]+)/news_(\d+)_(.*)\.html$ /newsItem.asp?cat=$1&cpID=$2&page=$3 [NC]
于 2013-05-05T07:05:39.360 回答