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: Directory/Sub Folder in Map file
Author
Message |
ckoziel
Newbie


Joined: 28 November 2011
Location: United States
Posts: 4
Posted: 28 November 2011 at 8:43am

Is it possible for the rewrite to have a directory/folder redirection in the map file?

Map File

219 about_us/index
223 about_Us/history

Reverse Map File

about_us/index 219
about_us/history 223

Here is the url:

http://localhost/page-1.asp?pageId=219

http://localhost/page-1.asp?pageId=223

I would like it to look like this

http://localhost/about_us/about/

http://localhost/about_us/history/

 

 

Back to Top Visit ckoziel's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 30 November 2011 at 4:07am

Hello,

Try using the following:

Code:
RewriteMap mapfile txt:mapfile.txt
RewriteMap revmapfile txt:revmapfile.txt

RewriteCond %{QUERY_STRING} ^pageId=(\d+)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^page-1\.asp$ /${mapfile:%1}? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${revmapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.*)$ /page-1.asp?pageId=${revmapfile:$1} [NC,L]



Regards
Andrew
Back to Top
 
ckoziel
Newbie


Joined: 28 November 2011
Location: United States
Posts: 4
Posted: 30 November 2011 at 11:50am

Andrew that worked great. Thanks for the reply. I do need one more step to complete the process.

1) Sometimes I may pass an id or offset paramater. I would like ISAPI rewrite to handle it if they exist. I don't want the paramaters to be stored in the mapfile.

For example the rewrite would look like this:

http://localhost/events/?offset=4

http://localhost/event_detail/[email protected]=2

 

Back to Top Visit ckoziel's Homepage
 
ckoziel
Newbie


Joined: 28 November 2011
Location: United States
Posts: 4
Posted: 30 November 2011 at 7:46pm

Andrew, also More Importantly.

I may have a page1-asp?pageId=x

I may have a page2-asp?pageId=x

I may have a page3-asp?pageId=x

I would need ISAPI Rewrite to redirect to to the proper "template page."

Right now the above example redirects all using the page-1.asp template.

Back to Top Visit ckoziel's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 01 December 2011 at 4:40am

We provide only basic rule on free basis. You may be interested in Premium Support Plan
I can suggest you to create separate rules for page2 and page3.

I'm not sure I understood what you meant by saying "I want ISAPI_Rewrite to handle the offset and id params"

Regards
Andrew
Back to Top
 
ckoziel
Newbie


Joined: 28 November 2011
Location: United States
Posts: 4
Posted: 01 December 2011 at 9:18am

Okay, you responded

"I can suggest you to create separate rules for page2 and page3."

I tried to add this but it interferes with the rule for page1. How can I rewrite the script above so it works for page1 or page2 or page3. For now we can forget about the other paramaters. Let me know if this will be free or if I need to pay.

Thanks

Back to Top Visit ckoziel's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 02 December 2011 at 5:20am

I'd suggest you use

RewriteRule ^page-1\.asp$ /1/${mapfile:%1}? [NC,R=301,L]
instead of
RewriteRule ^page-1\.asp$ /${mapfile:%1}? [NC,R=301,L]

So that when you rewrite back it'll be easier where to rewrite back.

Regards
Andrew
Back to Top
 

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

Printable version Printable version