Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule Duplicating Itself

         

boxfan

10:18 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



Hello,

I have the following link in my sidebar

RewriteRule category/bike_computers/$ /cgi-bin/commerce.cgi?search=action&category=0002&keywords=all&template=style/i/Storebuilder_Type1.html

It works great when in the home directory.

[mydomain.com...]

But when I go to the above URL the link in the sidebar becomes

[mydomain.com...]

and continues to duplicate the /category/ each time the sidebar link is clicked on.

I'm missing something in my rewrite rule.

Please help.

jdMorgan

11:43 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What produces the output seen in your 'sidebar'?

Mod_rewrite does not affect what is displayed in the 'page' that the browser displays, and it does not even affect the browser address bar when doing internal rewrites like yours (as opposed to external redirects).

Mod-Rewrite takes action after a request is received by your server, but before any content-handlers (or scripts) are invoked; It is a 'front-end' process in the UR:-to-filename translation phase, and not a 'content output filter' of any kind.

So the question is, how are the links in your 'sidebar' created?

Jim

boxfan

11:50 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



Yeah, that was my problem.

I was using ../category/bike_computers/ as the start of the link. Once I put the full domain name first like

[mydomain.com...] all is well.

Thanks for the quick response.

John

jdMorgan

1:37 am on Jan 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also use the server-relative link format (adjust to suit):

/category/bike_computers/

Since that relative URL starts with slash, it is taken to be relative to the domain, not relative to the the current page. To clarify things, bear in mind that it is the client (browser or robot) that resolves relative URLs. This often helps to make sense of some of the curious things you can run into when rewriting URLs.

Jim

boxfan

1:54 am on Jan 20, 2006 (gmt 0)

10+ Year Member



Ah, perfect.

Thank you.