Reputation: 3195
I am trying to get my code to accept an URL like the following:
www.mysite.com/something/something2/something3/something4
I have used the following code in my .htaccess so requests are run through an index.php file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
This works fine if the url is www.mysite.com/something.
However, if I change it to www.mysite.com/something/something2 I get a problem loading external files such as CSS.
Instead of loading the requested CSS file, it loads index.php.
This is only if there is more than 1 segment after the domain. Otherwise, it loads the CSS just fine.
Here is how I am loading the CSS:
<link rel="stylesheet" href="style.css" type="text/css" />
Upvotes: 1
Views: 56
Reputation: 2067
Since you're telling Apache to treat all URIs as index.php
, all your paths will need to be absolute, or relative to index.php
. For example:
<link rel="stylesheet" href="/style.css" type="text/css" />
(Originally commented)
Upvotes: 1