Forum Moderators: phranque
I am using mod rewrite on a php/mysql driven website.
I want to continue using relative linking to files in the root directory i.e. .css and .js files without having to use an absolute link.
I have:
RewriteRule ^(.*\.css)$ http://%{HTTP_HOST}/jbiv8/$1 [L]
The normal address is http://localhost/jbiv8/styles.css
It is not currently finding the stylesheet.
Any suggestions?
With thanks,
Will.
[edited by: jdMorgan at 2:55 pm (utc) on Jan. 18, 2008]
[edit reason] de-linked [/edit]
.*matches everything, with the slashes included, so if you place this into the server config, or your script is in a subdirectory, then you might get undesired results. So I'd suggest to change it as follows:
RewriteRule ([^/]+\.css)$ jbiv8/$1 [L]
Removed the start anchor (^), replaced the . with [^/] (which means anything but slash), replaced the * with + (asterisk: zero or more occurrences; plus sign: one or more occurrences), and finally removed the HTTP_HOST from the replacement pattern.