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: Rules building FAQ (Topic Closed Topic Closed)
Author
Message |
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 03 April 2006 at 4:00pm  

user wrote:


I have written a rule like:
Code:

RewriteRule /mypage/([^/]+)/([^/]+) /mypage.asp\?p1=$1&p2=$2 [I,L]

to rewrite URL http://mysite.com/mypage/value1/value2 to http://mysite.com/mypage.asp?p1=value1&p2=value2.

When I enter http://mysite.com/mypage/value1/value2 in a browser address bar I see page loaded but images and styles are broken. However, when I enter http://mysite.com/mypage.asp?p1=value1&p2=value2 all is working fine. What is happening?


You are using page-relative links to resources (like <img src="image.jpg">) and browser uses base path of a page to calculate a complete resource URL. By default base path is a page's parent folder.

So, for http://mysite.com/mypage.asp?p1=value1&p2=value2 URL base path will be http://mysite.com/ and calculated image link will be http://mysite.com/image.jpg.

But for http://mysite.com/mypage/value1/value2 base path will be http://mysite.com/mypage/value1/ and calculated image link will be http://mysite.com/mypage/value1/image.jpg. Which obviously will not work.

Thus, rule changing base path of a page could effectively break links to all page-relative resources.

There are at least three possible solutions:
1) Do not use rules changing base pathes of pages. For example, in this case rule
Code:

RewriteRule /mypage~([^~]+)~([^~]+) /mypage.asp\?p1=$1&p2=$2 [I,L]

could be used along with URLs like http://mysite.com/mypage~value1~value2.
2) Specify correct base folder for a page with the help of <base href="correct path"> tag. In this case it will be <base href="/">.
3) Replace all page-relative links with root-relative ones (like <img src="/image.jpg">).
Back to Top
 
Lexey
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Posts: 8119
Posted: 27 March 2007 at 7:54am  

user wrote:

I am trying to use HTTP_X_REWRITE_URL value to get originally requested URI but it returns rewritten URI not the original one. How to fix that?


You have manually added ISAPI_Rewrite.dll to a filters list for an IIS web site and have not removed it from global ISAPI filters list. Thus you have instructed IIS to call filter twice for each request. Second run overwrites X-REWRITE-URL header value. To fix that you have to remove one of those registrations.
Back to Top
 

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

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