jeffb
jeffb

Reputation: 15

htaccess rewrite rule with forward slash error

I have an htaccess rewrite rule setup to reroute the URL to index.php and have pretty SEO friendly URLs.

It looks like this:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./index.php [L]

This works great except that when for example I type www.site.com/one/two which reroutes to index.php but the css and image files are missing.

How do I allow for a slash in the link?

Upvotes: 0

Views: 313

Answers (1)

Manuel
Manuel

Reputation: 10303

When you add your css to the html add a / in front of the path like so:

<link href="/styles/index.css" rel="stylesheet" type="text/css" media="screen" />

That should fix your problem. You should do the same with javascript files.

That / tells the browser that the path is relative to the root of the website.

Upvotes: 1

Related Questions