Hi, this is my frst thread on this forum. I beg your indulgence. I am a graphic designer, who just learns how to code.
My problem is as follows:
I have set a local server on my computer for developing and testing websites. Using MAMP, if it's relevant. What should I write in my .htaccess file to redirect CSS files to the other file or folder I currently need?
After some tests I've managed to rewrite my style.css to test.css (in the same folder). The website with style.css has a style from test.css, so it seems work as I wanted.
My .htaccess looks like this:
RewriteRule ^css/(.*)?$ /Users/username/Sites/sitename/css/test.css [NC,L]
The problem is that it works with relative links only, when CSS file is declared on my website with:
<link href="css/style.css" rel="stylesheet" type="text/css">
While I need CSS with absolute link, just like that:
<link href="/css/style.css" rel="stylesheet" type="text/css">
Rewrite stops working then. None CSS file is loading now. In Safari's console I get such error:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8888/css/style.css
As you can see from the link in the error, browser looks for the file in localhost:8888/css/style.css because of the absolute link. Which is wrong, because the file isn't there. It can be accessed with localhost:8888/sitename/css/style.css or file:///Users/username/Sites/sitename/css/style.css
Please help. I don't know how to solve this.