I am using following mod_rewrite rule:
**RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ $1.php [L]**
to get clean url such as
www.myweb.com/login
from
www.myweb.com/login.php
I am using another rewrite rule
**RewriteRule ^itemdetail/([0-9]+)/?$ itemdetail.php?itemid=$1 [NC,L]**
to get
www.myweb.com/itemdetail/100008
from
www.myweb.com/itemdetail?itemid=100008.
This works fine but there is one problem. This rewrite rule add a subdomain on every link. for example. if the link to css file is text.css now the link to this css file is itemdetail/text.css. The link to home page is now http://www.myweb.com/itemdetail/home instead of http://www.myweb.com/home. What am I doing wrong here. Please help.
You can do one of two things to deal with this, either add this to the header of your
itemdetail.phppages (inside the<head> </head>tags):Or you can change your css links from relative to absolute URLs by adding a leading
/, example:Otherwise, you could try adding rewrite rules to un-write the css links, but that’s usually a really bad idea, as it’ll break css in subdirectories when you are intentionally using them: