RewriteMap help needed
9 posts
• Page 1 of 1
RewriteMap help needed
Hello all
Hope someone can help with a map file issue.
I'm trying to redirect from one url (including query string) to another place.
example of mapfile:
example of rule:
The issue seems to be the query string part.
Hope someone can help with a map file issue.
I'm trying to redirect from one url (including query string) to another place.
example of mapfile:
- Code: Select all
Product.aspx?abc=&Code=efgh test.cfm/abc/defghi/jklmnl/1234
example of rule:
- Code: Select all
RewriteMap mapfilemn txt:d:\ISAPI_Rewrite3\myfile.txt [NC]
RewriteCond %{HTTP:HOST} .*hostname.co.uk
RewriteCond ${mapfilemn:$1?%{QUERY_STRING}|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://www.hostname.co.uk/${mapfilemn:$1} [NC,R=301,L]
The issue seems to be the query string part.
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: RewriteMap help needed
Hello,
Lets try to taylor this in a different way:
REQUEST_URI matches both the body and the querystring. So I suggest in your mapfile you have:
Regards
Andrew
Lets try to taylor this in a different way:
- Code: Select all
RewriteMap mapfilemn txt:d:\ISAPI_Rewrite3\myfile.txt [NC]
RewriteCond %{HTTP:HOST} .*hostname\.co\.uk
RewriteCond %{REQUEST_URI} ^/(.*) [NC]
RewriteCond ${mapfilemn:%1|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://www.hostname.co.uk/${mapfilemn:$1} [NC,R=301,L]
REQUEST_URI matches both the body and the querystring. So I suggest in your mapfile you have:
Product.aspx?abc=&Code=efgh test.cfm/abc/defghi/jklmnl/1234
Regards
Andrew
Re: RewriteMap help needed
Thanks for replying.
Unfortunatley I had already tried what you suggested. All it returns is a 404... its the query string part that seems to be the issue![Sad :-(](./images/smilies/icon_e_sad.gif)
Unfortunatley I had already tried what you suggested. All it returns is a 404... its the query string part that seems to be the issue
![Sad :-(](./images/smilies/icon_e_sad.gif)
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: RewriteMap help needed
What makes you think so? Please, provide rewrite.log for a testing request.
Re: RewriteMap help needed
Unfortunately i cannot provide the log file as it is so long as we have over 20 websites.
However I tested it by removing the query part (anything after ?) in the mapfile and it redirected ok.
As soon as i put the query string back, it doesn't work.
So it looks like it isn't matching.
However I tested it by removing the query part (anything after ?) in the mapfile and it redirected ok.
As soon as i put the query string back, it doesn't work.
So it looks like it isn't matching.
Re: RewriteMap help needed
Okay... I've set up a test environment so that I can paste the log file.
Here is the rewrite code config
and here is the resulting log file contents:
It looks like {REQUEST_URI} doesn't contain the query string part ?!?!?!?
Here is the rewrite code config
- Code: Select all
RewriteMap mapfilemn txt:c:\ISAPI_Rewrite3\myfile.txt [NC]
RewriteCond %{HTTP:HOST} .*127.0.0.1
RewriteCond %{REQUEST_URI} ^/(.*) [NC]
RewriteCond ${mapfilemn:%1|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://127.0.0.1/${mapfilemn:$1} [NC,R=301,L]
and here is the resulting log file contents:
- Code: Select all
127.0.0.1 127.0.0.1 (2) init rewrite engine with requested uri /Product.aspx?5kg_Matrix_Anabolic_Protein=&Code=MA11
127.0.0.1 127.0.0.1 (1) Htaccess process request C:\ISAPI_Rewrite3\httpd.conf
127.0.0.1 127.0.0.1 (3) applying pattern '(.*)' to uri '/Product.aspx'
127.0.0.1 127.0.0.1 (4) RewriteCond: input='127.0.0.1' pattern='.*127.0.0.1' => matched
127.0.0.1 127.0.0.1 (4) RewriteCond: input='/Product.aspx' pattern='^/(.*)' => matched
127.0.0.1 127.0.0.1 (5) map lookup FAILED: map=mapfilemn[txt] key=Product.aspx
127.0.0.1 127.0.0.1 (4) RewriteCond: input='NOT_FOUND' pattern='!NOT_FOUND' => not-matched
It looks like {REQUEST_URI} doesn't contain the query string part ?!?!?!?
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: RewriteMap help needed
Looks like it. Strange. Okay... lets try:
What will the log show for this rule?
- Code: Select all
RewriteMap mapfilemn txt:c:\ISAPI_Rewrite3\myfile.txt [NC]
RewriteCond %{HTTP:HOST} .*127.0.0.1
RewriteCond %{REQUEST_URI} ^/(.*) [NC]
RewriteCond %{QUERY_STRING} (.*)
RewriteCond ${mapfilemn:%1\?%2|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://127.0.0.1/${mapfilemn:$1\?%2} [NC,R=301,L]
What will the log show for this rule?
Re: RewriteMap help needed
thanks... looking a bit better but still issue:
the log file is this:
the log file is this:
- Code: Select all
127.0.0.1 127.0.0.1 (2) init rewrite engine with requested uri /?5kg_Matrix_Anabolic_Protein=&Code=MA11
127.0.0.1 127.0.0.1 (1) Htaccess process request C:\ISAPI_Rewrite3\httpd.conf
127.0.0.1 127.0.0.1 (3) applying pattern '(.*)' to uri '/'
127.0.0.1 127.0.0.1 (4) RewriteCond: input='127.0.0.1' pattern='.*127.0.0.1' => matched
127.0.0.1 127.0.0.1 (4) RewriteCond: input='/' pattern='^/(.*)' => matched
127.0.0.1 127.0.0.1 (4) RewriteCond: input='5kg_Matrix_Anabolic_Protein=&Code=MA11' pattern='(.*)' => matched
127.0.0.1 127.0.0.1 (5) map lookup FAILED: map=mapfilemn[txt] key=?5kg_Matrix_Anabolic_Protein=&Code=MA11
127.0.0.1 127.0.0.1 (4) RewriteCond: input='NOT_FOUND' pattern='!NOT_FOUND' => not-matched
127.0.0.1 127.0.0.1 (2) init rewrite engine with requested uri /welcome.png
127.0.0.1 127.0.0.1 (1) Htaccess process request C:\ISAPI_Rewrite3\httpd.conf
127.0.0.1 127.0.0.1 (3) applying pattern '(.*)' to uri '/welcome.png'
127.0.0.1 127.0.0.1 (4) RewriteCond: input='127.0.0.1' pattern='.*127.0.0.1' => matched
127.0.0.1 127.0.0.1 (4) RewriteCond: input='/welcome.png' pattern='^/(.*)' => matched
127.0.0.1 127.0.0.1 (4) RewriteCond: input='' pattern='(.*)' => matched
127.0.0.1 127.0.0.1 (5) map lookup FAILED: map=mapfilemn[txt] key=welcome.png?
127.0.0.1 127.0.0.1 (4) RewriteCond: input='NOT_FOUND' pattern='!NOT_FOUND' => not-matched
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: RewriteMap help needed
Well, you requested "/?5kg_Matrix_Anabolic_Protein=&Code=MA11", ISAPI_Rewrite looked for "?5kg_Matrix_Anabolic_Protein=&Code=MA11". Didn't find it in a mapfile.
What entry did you have in mapfile?
Rgards
Andrew
What entry did you have in mapfile?
Rgards
Andrew
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 22 guests