breaking links when url is not rewriten with "R" switch

Oct 3, 2008 at 7:58 PM
Edited Apr 10, 2009 at 1:29 PM
how do you guys deal with this problem when you can not edit the actual aspx pages?
(our code pages are from a 3rd party and we can't rely on changing their code files as updates will likely break things)

my filter:
ReWriteCond %{SERVER_PORT} ^80$
ReWriteCond %{HTTP_HOST} ^(www\.fcp\.com)(.*)$ [I]
RewriteRule ^/(.*) http://fcp.com/$1 [I,R]
# actual url:
#  http://fcp.com/items.aspx?Code=SMS&key=cat
# friendly url:
#  http://fcp.com/img/sms/  (with our w/out trailing "/")
ReWriteRule ^(.*)/(img)/(sms)/?$ $1/items.aspx?Code=SMS&key=cat [I,R,U,L]

* note: neither "img" nor "sms" are physical directories on our web server *

with the "R" switch on this rule:  ReWriteRule ^(.*)/(img)/(sms)/?$ $1/items.aspx?Code=SMS&key=cat [I,R,U,L]
http://fcp.com/img/sms
redirects properly to
http://fcp.com/items.aspx?Code=SMS&key=cat
and maintains all css and image associations.

The problem is that the url is actually rewritten in the browser's address bar to "http://fcp.com/items.aspx?Code=SMS&key=cat"
That defeats the purpose, as now the url is ugly - and any bookmarking or linking that the visitor does will likely be with the ugly url - not my clean url.

If I remove the "R" switch from the rule ...
ReWriteRule ^(.*)/(img)/(sms)/?$ $1/items.aspx?Code=SMS&key=cat [I,U,L]

the url is not rewritten in the browser's address bar, but links throughout the page change - which breaks css and images (and possibly other hard links).

thanks!
Coordinator
Oct 4, 2008 at 12:33 AM
see the other thread on the same same topic -
by b01

Oct 6, 2008 at 2:25 PM
Edited Apr 10, 2009 at 1:37 PM
this post: http://www.codeplex.com/IIRF/Thread/View.aspx?ThreadId=32557
suggests using HTTP_X_REWRITE_URL but I don't see any examples of that in the readme.

I have tried using (and not using) the R switch.  I have also tried using the "U" switch.

D:\<path>\ASP.NET Template is my root directory. "img" is not an actual directory.


Coordinator
Oct 6, 2008 at 8:48 PM

fcp, I'm not sure what you are asking.

I've read the readme multiple times but do not understand what I need to be doing with the switches to or HTTP_X_REWRITE_URL to use the actual path.

What actual path? And when you say "use the actual path", what do you mean by "use" ?

if you can speak my language , I might be able to help you.

Oct 6, 2008 at 9:00 PM
thanks Cheeso

see this thread instead:
http://www.codeplex.com/IIRF/Thread/View.aspx?ThreadId=37132

I think I cleared up what I was asking for on that thread enough that you'll be able to understand what I'm asking.


let's give up on this one.
I was able to get most of what I wanted by adding base href http://fcp.com in the master page file for our site