Rewrite Rule with optional parameter iis7.5
15 posts
• Page 1 of 1
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Rewrite Rule with optional parameter iis7.5
Hi there
I have a rewrite rule setup for the news section of our site. The rule is as follows:
This will rewrite links like this:
This works fine however when it comes to links from places like twitter they place tracking code after the .html as follows:
Of course this doesn't work because of the $ after the .html in the rewrite rule. However I have been given the following code to try, which I thought might work but doesn't:
Does anybody have any clues on how I can fix this?
Many thanks in advance for any help.
Graham
I have a rewrite rule setup for the news section of our site. The rule is as follows:
- Code: Select all
Rewriterule ^/motorcycle_news/categories/(.*?)/news_(\d+)_(.*)\.html$ /newsItem.asp?cat=$1&cpID=$2&page=$3 [NC]
This will rewrite links like this:
- Code: Select all
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-“very-important”.html
This works fine however when it comes to links from places like twitter they place tracking code after the .html as follows:
- Code: Select all
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%E2%80%9Cvery-important%E2%80%9D.html?utm_source=dlvr.it&utm_medium=twitter
Of course this doesn't work because of the $ after the .html in the rewrite rule. However I have been given the following code to try, which I thought might work but doesn't:
- Code: Select all
RewriteCond %{QUERY_STRING} ^(utm_source=.*&utm_medium=.*)?$ [NC]
Rewriterule ^/motorcycle_news/categories/([^/]+)/news_(\d+)_(.*)\.html$ /newsItem.asp?cat=$1&cpID=$2&page=$3 [NC]
Does anybody have any clues on how I can fix this?
Many thanks in advance for any help.
Graham
Re: Rewrite Rule with optional parameter iis7.5
I guess you are looking for [QSA] flag
QSAppend or QSA — appends query string of the original request to the Substitution string (regardless of whether Substitution has new query string or not). It may be useful when you need add new query string parameters but also preserve the originally requested ones
Please try
RewriteRule ^/motorcycle_news/categories/(.*?)/news_(\d+)_(.*)\.html$ /newsItem.asp?cat=$1&cpID=$2&page=$3 [NC,QSA]
QSAppend or QSA — appends query string of the original request to the Substitution string (regardless of whether Substitution has new query string or not). It may be useful when you need add new query string parameters but also preserve the originally requested ones
Please try
RewriteRule ^/motorcycle_news/categories/(.*?)/news_(\d+)_(.*)\.html$ /newsItem.asp?cat=$1&cpID=$2&page=$3 [NC,QSA]
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
Hi Sergey,
I have tried this but it doesn't work unfortunately. The people who tweet our news articles on our website want to be able to track where users are coming from hence appending to the original URL. The problem I have been faced with is that, if I remove the $ from after the .html part of the rewrite rule then of course it works. However the problem with this is that each of the url's also fail on with PCI compliance because cross scripting code can also be added to the URL and can be executed.
Therefore I only want to be able to add Google's tracking code to the links only so they would be considered optional:
Cheers
Graham
I have tried this but it doesn't work unfortunately. The people who tweet our news articles on our website want to be able to track where users are coming from hence appending to the original URL. The problem I have been faced with is that, if I remove the $ from after the .html part of the rewrite rule then of course it works. However the problem with this is that each of the url's also fail on with PCI compliance because cross scripting code can also be added to the URL and can be executed.
Therefore I only want to be able to add Google's tracking code to the links only so they would be considered optional:
- Code: Select all
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%E2%80%9Cvery-important%E2%80%9D.html(?utm_source=dlvr.it&utm_medium=twitter)
Cheers
Graham
Re: Rewrite Rule with optional parameter iis7.5
Could you please show rewrite.log for
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%E2%80%9Cvery-important%E2%80%9D.html?utm_source=dlvr.it&utm_medium=twitter
request
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%E2%80%9Cvery-important%E2%80%9D.html?utm_source=dlvr.it&utm_medium=twitter
request
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
I am not sure what is going on but I cannot get the rewrite.log file to be written to. I have setup httpd.conf and the error.log file is showing but even though the directive to write to the rewrite.log file is in place it does not seem to work.
Do you have any thoughts on this?
Sorry Graham
Do you have any thoughts on this?
Sorry Graham
Re: Rewrite Rule with optional parameter iis7.5
Please try to grant NTFS write permissions for rewrite.log file for Everyone and perform iisreset
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
Ok, that worked thank you. Here is the log for a successful transaction:
Of course trying to run it with the tracking details on the end of the URL doesn't work and so of course nothing logs at all.
Many thanks for all your help.
Graham
- Code: Select all
217.32.220.226 217.32.220.226 Tue, 07-May-2013 14:14:41 GMT [www.phmotorcycles.co.uk/sid#6][rid#23887320/initial] (3) applying pattern '^/motorcycle_news/categories/([^/]+)/news_(\d+)_(.*)\.html$' to uri '/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-�very-important�.html'
217.32.220.226 217.32.220.226 Tue, 07-May-2013 14:14:41 GMT [www.phmotorcycles.co.uk/sid#6][rid#23887320/initial] (1) Rewrite URL to >> /newsItem.asp?cat=motorcycle-parts&cpID=801580922&page=rossi-jerez-is-�very-important�
217.32.220.226 217.32.220.226 Tue, 07-May-2013 14:14:41 GMT [www.phmotorcycles.co.uk/sid#6][rid#23887320/initial] (2) rewrite '/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-�very-important�.html' -> '/newsItem.asp?cat=motorcycle-parts&cpID=801580922&page=rossi-jerez-is-�very-important�'
Of course trying to run it with the tracking details on the end of the URL doesn't work and so of course nothing logs at all.
Many thanks for all your help.
Graham
Re: Rewrite Rule with optional parameter iis7.5
Seems request interrupted before ISAPI_Rewrite.
You can use "Failed request tracing" tool in Iis for debug this issue, please provide us with this logs
You can use "Failed request tracing" tool in Iis for debug this issue, please provide us with this logs
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
I have done that and the XML log is attached to this post.
I hope this helps.
Cheers
Graham
I hope this helps.
Cheers
Graham
- Attachments
-
failedRequestLog.txt.zip
- (7.84 KiB) Downloaded 781 times
Re: Rewrite Rule with optional parameter iis7.5
We need freb.xsl too, please zip all folder with log
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
Sergey, hi
Many thanks here are the required files.
Cheers
Graham
Many thanks here are the required files.
Cheers
Graham
- Attachments
-
FailedRequestLog.zip
- (23.01 KiB) Downloaded 770 times
Re: Rewrite Rule with optional parameter iis7.5
Sorry but I can't see target url, only
http://www.phmotorcycles.co.uk:80/usedbikes/10128/[l]/images/biketraderimages/{ds::imgfile}
please request
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%E2%80%9Cvery-important%E2%80%9D.html?utm_source=dlvr.it&utm_medium=twitter
http://www.phmotorcycles.co.uk:80/usedbikes/10128/[l]/images/biketraderimages/{ds::imgfile}
please request
http://www.phmotorcycles.co.uk/motorcycle_news/categories/motorcycle-parts/news_801580922_rossi-jerez-is-%E2%80%9Cvery-important%E2%80%9D.html?utm_source=dlvr.it&utm_medium=twitter
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
Sergey, good afternoon
Hope you are well. Please find attached the failed request log.
Cheers for all your help.
Graham
Hope you are well. Please find attached the failed request log.
Cheers for all your help.
Graham
- Attachments
-
FailedRequestLog.zip
- (23.41 KiB) Downloaded 773 times
Re: Rewrite Rule with optional parameter iis7.5
Will this work?
- Code: Select all
Rewriterule ^/motorcycle_news/categories/(.*?)/news_(\d+)_(.*)\.html(\?(.*))?$ /newsItem.asp?cat=$1&cpID=$2&page=$3(?4&$4) [NC]
- spydersweb
-
- Posts: 8
- Joined: 07 May 2013, 04:34
Re: Rewrite Rule with optional parameter iis7.5
Phil, hi
YOU ARE AN ABSOLUTE ******************************* STAR!
Thank you so much, that worked a charm.
Cheers
Graham
YOU ARE AN ABSOLUTE ******************************* STAR!
Thank you so much, that worked a charm.
Cheers
Graham
15 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 20 guests