This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Problem with URL re-write since IIs 7
Author
Message |
musosmiffy
Newbie


Joined: 11 May 2009
Location: United Kingdom
Posts: 6
Posted: 31 August 2011 at 8:42am

Hi,

I have used the following code/conditions for some years on Win 2003 & IIS 6 with out problem. Since moving over to Win 2008 and IIS 7 a problem has occured.

CODE

RewriteCond %{QUERY_STRING} ^in=(.*)$
RewriteRule ^/instructors\.asp$ instructors/lessons/%1? [I,R=301]

#URL Friendly instructors.asp
RewriteRule ^/instructors/lessons/(.*)$ /instructors.asp?in=$1 [I,L]

OBJECTIVE

Re-write instructors.asp?in=some town

to

instructors/lessons/some town

PROBLEM

Everything works okay if the parameter is a single word town e.g. 'sometown'.

However, if the town name is 'some town', the resultant page URL is:
instructors/lessons/some+town

That provides a 404 error.

If I go to instructors.asp?in=some+town then the page is displayed correctly.

I really want the page to work and also show the URL as:
instructors/lessons/some town

Any ideas please?
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 31 August 2011 at 9:16am

First, please consult this article http://www.helicontech.com/articles/plus-sign-in-iis7/, it might be helpful.
If it doesn't help, please provide rewrite.log records for the failing request,

__________________
Regards,
Anton
Back to Top
 
musosmiffy
Newbie


Joined: 11 May 2009
Location: United Kingdom
Posts: 6
Posted: 31 August 2011 at 9:25am

Wow, that was quick and it sorted it. Many thanks Anton!

I had spent 6 hours trying to work that out!

It now works okay but is there anyway to remove the '+' sign in the url shown in the browser - it shows as:
instructors/lessons/quintrell+downs

I can type in instructors/lessons/quintrell downs and the page displays fine and without the '+'.

Thanks.
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 31 August 2011 at 9:35am

You'll have to write a rule to replace pluses with spaces, like:

RewriteRule (.*)\+(.*) $1\s$2 [LP,R=301,L]

__________________
Regards,
Anton
Back to Top
 
musosmiffy
Newbie


Joined: 11 May 2009
Location: United Kingdom
Posts: 6
Posted: 31 August 2011 at 9:56am

Thanks Anton. That does remove the + but replaces it with an 's'. I can see that \s is a shortcut for a space but it doesn't seem to want to work here?
Back to Top
 
musosmiffy
Newbie


Joined: 11 May 2009
Location: United Kingdom
Posts: 6
Posted: 31 August 2011 at 10:29am

I cracked it with your help and another forum post. This worked:
RewriteRule (.*)\+(.*) $1\%20$2 [NE,LP,R=301,L]

The key is the \ before the %20 and using the No Escape (NC) at the end.

Thanks again. 
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version