This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Help with creating URL Rewite ..
Author
Message |
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 10 June 2009 at 2:45pm

I am having trouble getting this working.. and I know I am just doing it wrong... I can't grasp the concept... I wanted to make a filter that did not use "/" because then all my links for 1000s of websites and pages would have to be changed to absolute paths, which is not possible.

RewriteRule (.*default.asp)(\?[^/]*)?[/.]([^-]*)-([^/]*)(.*) $1(?2$2&:\?)$3=$4$5 [N,I]
RewriteRule (.*).default.asp(\?[^/]*)? $1/default.asp$2 [I,L]

original URL:
mydomain.com/default.asp?f=myvar1&d=myvar2&id=myvar3

The variables will vary, they will be different depending on the page, etc.

I just really want to "re-interpret" the ? and & signs and automatically fill in the 'default.asp', so something like:

mydomain.com/default.asp?f=myvar1&d=myvar2&id=myvar3

would be:
mydomain.com/f-myvar1.d-myvar2.id-myvar3

The page is always default.asp.

Also, how would I make this a default rule for the sites in IIS? Also I would assume that if I have other sites who have a different rules, the .httpd file in their root directory would override whatever the default is, is that correct?
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 11 June 2009 at 3:56pm

Try this:

RewriteRule ([^?]*/)(?:(\?[^.]*)\.)?([^-?]+)-([^.]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS]
RewriteRule ([^?]*/)(\?.*)? $1default.asp$2 [I,L]

Quote:
Also, how would I make this a default rule for the sites in IIS?


Add it to the global httpd.ini

Quote:
Also I would assume that if I have other sites who have a different rules, the .httpd file in their root directory would override whatever the default is, is that correct?


No, global rules always execute before site-specific ones.
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 15 June 2009 at 7:10pm

Ok, I added the rule, but now if I go to http://mydomain.com/splash.asp the page does not load.. it just sits there... once I comment out the rule and save the httpd.ini, it loads, when uncomment it out, it does not load.. any ideas why this would happen?

All other pages seem to load fine.
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 16 June 2009 at 2:55pm

The given rule can not affect this URL. But it may affect some related resouces (like images, etc). So, check IIS log to see what is happening.
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 26 February 2010 at 12:42pm

Ok, I figured out what was happened. We also use the page splash.asp and when trying to access this page, it does not load, I'm guessing because it is trying to translate /splash.asp as well. So I am guessing that rule won't work for us, since there are still a few cases were the page is actually different than default.asp.

What about a rule like:
mydomain.com/default.asp.f-myvar1.d-myvar2.id-myvar3

Maybe that would be best? Can you let me know how to write this rule, everything I am trying does not work or the page does not load. Thanks a bunch!
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 01 March 2010 at 12:09pm

Try this:

RewriteRule (/default\.asp)(?:(\?[^.]*))?\.([^-?]+)-([^.]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 01 March 2010 at 8:50pm

So sorry, I need a rule that would work with any page, including splash.asp, default.asp, etc.

So would it be:
(/*\.asp)(?:(\?[^.]*))?\.([^-?]+)-([^.]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]

Is this correct?
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 02 March 2010 at 10:02am

RewriteRule ([^?]+\.asp)(?:(\?[^.]*))?\.([^-?]+)-([^.]*)(.*)
$1(?2$2&:\?)$3=$4$5 [NS,I]
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 02 March 2010 at 11:39am

perfect thanks!. I'll let you know if I run into any issues.
Back to Top Visit linkusystems's Homepage
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 08 March 2010 at 12:49pm

Found some issues with this method... let me know if there is an easy fix. Basically it works, but in some pages we pass values in the querystring, for example:

default.asp?f=something&d=something&domain=somedomain.com&var=1&var=2

This does not work because of the .com, causes an issue with the filter. Same for other values that could be in the querystring, such as "Main St." or "54.32".

I was going to try and write scripts to replace these "." with something else,then replace them out again when needed, but was wondering if maybe if you have any ideas.
Back to Top Visit linkusystems's Homepage
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 08 March 2010 at 12:55pm

Another issue, is sometimes we have a URL such as:
default.asp?f=download&filename=myfile.pdf&var=1

This can cause some issues as well.

Maybe can we use conditions, for example if we are using the normal querystrings, such as ? and & , do not use . and -.. only use those when we use "default.asp." does that make sense?
Back to Top Visit linkusystems's Homepage
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 08 March 2010 at 1:06pm

I just wanted to provide more clarification.. is it possible to do a conditional rewrite. As not all our URLs need to use the rewritten URL. Most our URLs use the standard format, but there are a select few pages where we need to use the rule (created above).

So it would be great if we could have a statement that worked like an if then statement...

if 'default.asp.' is in the URL, then use the rule, if 'default.asp?' is in the URL, then don't use any rewrite rules.

Is this possible?
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 09 March 2010 at 5:44am

Place the following rule before the previous one:

RewriteRule [^?]*/default\.asp\?.* $0 [I,L]
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 18 March 2010 at 1:31am

everything seems to be working pretty well, but had a slight hiccup. For some reason thei above rule is not working for this URL:

http://www.newheightsrealty.com/frame.asp?frameurl=http://www.nypl.org/locations/fort-washington

Because there is a . and a - in the URL, it is treating it differently. Should I write a script to maybe find and replace, or is there a solution to fix it in the rewrite? Whichever you think would have less side effects. Thanks!
Back to Top Visit linkusystems's Homepage
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 22 March 2010 at 11:03pm

Here's another example of a URL not working properly...
http://wildrealty.com/website/photo_large.asp?photourl=http://photos.linkurealty.com/listing_pictures/4106/3ef5ab4f-169c-4221-9ea1-bdfac42f5576.jpg

cuts off after the "photos."
Back to Top Visit linkusystems's Homepage
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 22 March 2010 at 11:07pm

RewriteRule [^?]*/default\.asp\?.* $0 [I,L]

I figured I could just add a new rule such as:
RewriteRule [^?]*/frame.asp\.asp\?.* $0 [I,L]
and RewriteRule [^?]*/photo_large\.asp\?.* $0 [I,L]

which seems to work. I suppose this is probably the best method then?
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 23 March 2010 at 11:09am

It would be better to combine these 3 rules into a single rule:

RewriteRule [^?]*/(?:default|frame|photo_large)\.asp\?.* $0 [I,L]
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 21 April 2010 at 10:55am

So, these rules are in the global, since it applies to 99% of our sites, but how would i disable these rules for specific sites? I tried putting a httpd.ini file in the root with no rules, but no luck.
Back to Top Visit linkusystems's Homepage
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 23 April 2010 at 5:57am

There is no way to override global rules on a site level. But you could completely disable rewriting for choosen sites (DisableRewrite directive).
Back to Top
 
linkusystems
Newbie


Joined: 07 October 2004
Location: United States
Posts: 30
Posted: 28 April 2010 at 12:55pm

Ok, so how would I do that.. we are using IIS 7 on Windows Server 2008.

Like this? DisableRewrite SiteNumber

DisableRewrite 678

Where do I put this in the global, at the top above the rules?. I just want to make sure so I don't cause any downtime on my sites. thanks!
Back to Top Visit linkusystems's Homepage
 

Page of 2 Next >>
 
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum