Newbie Question

Topics: Developer Forum, Project Management Forum, User Forum
Jul 6, 2009 at 8:30 PM

My apologies if this has been discussed before. I did search the forum and found no relevant responses. Anyway, I've successfully installed IIRF. I have also set up my first rewrite rule. It was pretty simple and it works great. However, I am having one issue... or at least I think it is an issue. For this rule:


RewriteRule ^/shopbycategory/apparel.html   /shopbycategory.cfm?cl1id=1


When I view the page on --- the page loads, but no css, images or javascript are displayed/working. I have to hardcode all css, images or javascript with fully qualified domain names to render the page properly.

Is there something I am doing wrong? Can I get my template to work correctly w/o hardcoding these tags with FQDNs?

Regards, cfdev

Jul 6, 2009 at 10:49 PM

Yes, this is a common problem people run into.

You can solve it by rewriting the CSS and JPGs (etc) just as you rewrite the HTML.

Here's how to think about it.  The URL that is being submitted is . Now, that request gets rewritten on the server side, but the client is not aware of that.  All relative links within the returned HTML are considered relative to the requested URL, which is /shopbycat/apparel.htm .   So if there is a link for style.css in the html, then the browser will make a request for  Now I am guessing that shopbycategory is not a real directory on your server, and that URL is not going to be satisfied.    But, you can allow requests for such URLs to be satisfied by rewriting them as well.   So...

RewriteRule ^/shopbycategory/(.+\.(css|jpg|js))$    /$1   [L]

This allows your relative links to be resolved on the server side.

another option is to make the various links absolute, hence something like /scripts/foo.js, /styles/style.css, and /images/image1.jpg, with a leading slash.

Jul 7, 2009 at 12:23 PM

Thanks Cheeso! Your explanation was perfect! I can't beleive I didn't think to use the leading slash.

Have a good one! More questions to come...