Link to home
Start Free TrialLog in
Avatar of adavir
adavir

asked on

ISAPI ReWrite

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
Avatar of netmunky
netmunky
Flag of United States of America image

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]
Avatar of adavir
adavir

ASKER

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




Avatar of adavir

ASKER

PS I know that the rule is commented out
ASKER CERTIFIED SOLUTION
Avatar of netmunky
netmunky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adavir

ASKER

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