I'm using .htaccess to rewrite my urls so "index.php?p=something" can be written as "pages/something" or "pages/something/" instead. (with or without the trailing / )
My .htaccess file:
RewriteEngine on
RewriteRule ^page/(.+?)/?$ index.php?p=$1
Problem is that I link relatively to files (css and other) from the pages that gets their url rewritten.
The browser obviously believes that the files are relative to "/pages/something/" but those folders doesn't exist.
I would really like to avoid linking to files with their absolute paths (horror while developing locally and testing on the real web-server) so what should I do so the browser still get the correct files?
Do I have to rewrite the rewritten url back again if it links to files (maybe if there is a dot(.) in the path?)
Question
Andos
I'm using .htaccess to rewrite my urls so "index.php?p=something" can be written as "pages/something" or "pages/something/" instead. (with or without the trailing / )
My .htaccess file:
Problem is that I link relatively to files (css and other) from the pages that gets their url rewritten.
The browser obviously believes that the files are relative to "/pages/something/" but those folders doesn't exist.
I would really like to avoid linking to files with their absolute paths (horror while developing locally and testing on the real web-server) so what should I do so the browser still get the correct files?
Do I have to rewrite the rewritten url back again if it links to files (maybe if there is a dot(.) in the path?)
Link to comment
https://www.neowin.net/forum/topic/658080-url-rewrite-and-relative-file-paths/Share on other sites
5 answers to this question
Recommended Posts