[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ISAPI ReWrite

Posted on 2007-10-04
5
Medium Priority
?
769 Views
Last Modified: 2008-01-09
Hi I am using ISAPI Rewrite

What rule should i specify to change

/viewArticle.aspx?ArticleId=125
/viewArticle.aspx?ArticleId=121
/viewArticle.aspx?ArticleId=122
etc

to
/Article_125.htm
/Article_121.htm
/Article_122.htm


Regards

Paul
0
Comment
Question by:adavir
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:netmunky
ID: 20019594
i believe ISAPI rewrite uses similar rules to mod_rewrite. if so, try

RewriteCond %{THE_REQUEST} \ /Article_([0-9]+).htm([^\ ]*)(\?.|\ .)
RewriteCond %{REQUEST_FILENAME} !viewArticle.aspx
RewriteRule .  /viewArticle.aspx?ArticleId=%1 [QSA,L]
0
 

Author Comment

by:adavir
ID: 20021899
thanks, we cracked it yesterdaty

However we encountered another problem,

Our site has 3 main files in the root directory

viewArticle.aspx?ArticleId= (ID) or (String)
viewArticleCategory.aspx?ArticleCategoryId= (ID) or (String)
viewArticleTopic.aspx?ArticleTopicId= (ID) or (String)

We have the ISAPI configured like follows

# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.26

RewriteEngine on
RewriteBase /

# Base Rule


# ARTICLE STUFF


# RewriteRule ^(.*?)\.html /viewArticle.aspx?articleId=$1 [QSA, NC]


# CATEGORY STUFF


RewriteRule ^[^.]*/[^.]*$ /viewArticleCategory.aspx?ArticleCategoryId=$0  [NC,QSA]
RewriteRule ^[^.]*/[^.]*/[^.]$ /viewArticleCategory.aspx?ArticleCategoryId=$0  [NC,QSA]


# TOPIC STUFF

#RewriteRule ^[^.]+$ /viewArticleTopic.aspx?ArticleTopicId=$0  [NC,QSA]


# RewriteRule ^(?!/admin)/[^\n]*/([^\n]*).aspx[^.]* /$1.aspx  [NC,QSA]

RewriteRule ^[^.]*viewArticle([^\n]*).aspx /viewArticle$1.aspx  [NC,QSA]

Our URLs work fine

So a Topic would like as
/OurServices

A category or sub category would work as follows

/OurServices/Tax/Calulations

and an Article would look as follows

/OurServices/Tax/Calulations/Test.htm

However our Post backs didnt work when the url had a directory out side the root so on post back it would come back with the file /OurServices/Tax/ViewArticleCategory.aspx could not be found.

So to resolve this we put in the line

RewriteRule ^[^.]*viewArticle([^\n]*).aspx /viewArticle$1.aspx  [NC,QSA]

To redirect all request for these files to the root files. BUT in our admin pages we have files of the same name. for instance /admin/contentManager/viewArticle.aspx so when you click on our admin pages you get back to the font end.

so we tried

# RewriteRule ^(?!/admin)/[^\n]*/([^\n]*).aspx[^.]* /$1.aspx  [NC,QSA]

But doesnt work

Any Ideas

Paul




0
 

Author Comment

by:adavir
ID: 20021913
PS I know that the rule is commented out
0
 
LVL 8

Accepted Solution

by:
netmunky earned 1500 total points
ID: 20022130
your forms are likely using something like <form action="viewArticle.aspx">
an easy fix that doesn't require isapi rewrite is to change them to <form action="/viewArticle.aspx">
i'm not sure what the ASP equivelant is, but in PHP you could do <form action="<?=$_SERVER['PHP_SELF']?>">
0
 

Author Comment

by:adavir
ID: 20084378
ASP.NET doesnt allow you to change the Action Attribute, if you do it will default to what it should be. Even using Javascript this cant be accomplished which I found interesting. This highlights the problem in the first place as if .NET generated a fully qualified link for the action i wouldnt have gotten that error.

Regards

Paul
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question