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: Help with Query String
Author
Message |
sandeepGonthkar
Newbie


Joined: 15 November 2011
Location: India
Posts: 6
Posted: 15 November 2011 at 9:10am

Hi All,

I am stuck in a place and really need help.

my current application works for the below link

http://www.hostname.com/searchpage.aspx?cat=\books\children\games and i need to rewrite it to

http://www.hostname.com/search/books/children/games,

I wrote a rule as  below.

RewriteRule ^/search(.*) /searchpage.aspx?cat=$1

but this will yield the url as

http://www.hostname.com/searchpage.aspx?cat=/books/children/games .

i need the querystring with BackSlash("\"). any help is really appriciated.

 



__________________
Sandy
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 16 November 2011 at 2:35am

You can only achieve this manually, as the request comes with forward slashes.

Like this:

RewriteRule ^/search/([^/.]+)/([^/.]+)/([^/.]+)/? /searchpage.aspx?cat=$1\\$2\\$3 [NC,L]

__________________
Regards,
Anton
Back to Top
 
sandeepGonthkar
Newbie


Joined: 15 November 2011
Location: India
Posts: 6
Posted: 16 November 2011 at 4:45am

Thanks for the reply Anton,

Sorry forgot to mention earlier... the requests are dynamic and the number can range from 1 to 100. hence it is not possible to write it manually.

Can you please help me here.

 



__________________
Sandy
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 16 November 2011 at 8:27am

Ok, let's try this kind of magic:

RewriteRule ^(/search/[^/.]+)/(.+)$ $1\\$2 [NC,LP]
RewriteCond %{REQUEST_URI} \\
RewriteRule ^/search/([^/]+) /searchpage.aspx?cat=$1 [NC,L]

__________________
Regards,
Anton
Back to Top
 
sandeepGonthkar
Newbie


Joined: 15 November 2011
Location: India
Posts: 6
Posted: 17 November 2011 at 1:40am

Thanks for the suggestion Anton.

Can you please explain this to me.. I am really a new bie
here.. and to implement this i need to understand this
first.

I tried to figure this out myself, but have not been able
to get through this.

Thanks a lot.

__________________
Sandy
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 17 November 2011 at 3:24am

Well, the idea is to replace slashes with back-slashes while there are any. This is done with the help of LP (loop) flag which applies the
rule while the pattern gets matched. This is the first, preparatory step.
And on the second step this URL with backslashes is rewritten in a way you need.


__________________
Regards,
Anton
Back to Top
 
sandeepGonthkar
Newbie


Joined: 15 November 2011
Location: India
Posts: 6
Posted: 17 November 2011 at 3:50am

Thanks a lot Anton. you have really saved my day.

This has indeed worked like a Magic.
I am able to get the URL as in need it, but when the page
loads it breaks the CSS.

Any clues....

__________________
Sandy
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 17 November 2011 at 4:52am

The following conditions must help:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(/search/[^/.]+)/(.+)$ $1\\$2 [NC,LP]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \\
RewriteRule ^/search/([^/]+) /searchpage.aspx?cat=$1 [NC,L]

__________________
Regards,
Anton
Back to Top
 
sandeepGonthkar
Newbie


Joined: 15 November 2011
Location: India
Posts: 6
Posted: 20 November 2011 at 9:46am

Hi Anton,

Thank you very much for the suggestion and finally i have got through this problem.

Your inputs were really life saving.
But the above issue(CSS breaking) did not solve with your suggestion.
I had to dig a lot and accidentally i found out on Helicon help files, that looping will change the Base Directory, to over come  this, we to explicitly mention the root folder in the HTML Head.

<base href="www.hostname.com"/>

adding the above in my html code, solved the problem

Thanks once again.


__________________
Sandy
Back to Top
 

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

Printable version Printable version