Skip to content Skip to sidebar Skip to footer

A Way To Avoid Apache Alias Path To Include Html Resources Like Css

Here comes a question because my current solution is not really satisfying me for the following problem: I have an own PHP Framework with MVC pattern in development. And my Router

Solution 1:

You must use absolute paths instead of relative paths for your html links (css, javascript, images, etc).

For example:

<link rel="stylesheet"type="text/css" href="/style/include/css/style.css" />

The leading slash (before style) means to begin from document root folder, then go into style folder, and so on... (you may have another prefixed directory if it's not in root folder)

You had some problems because some of your rules can create virtual directories (e.g: http://domain.com/some/directory/subdirectory/etc/).

Also, in your htaccess, it wouldn't hurt to use a leading slash (or a RewriteBase)

Options -Indexes
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /index.php [L]

or (both are the same)

Options -Indexes

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php[L]

Post a Comment for "A Way To Avoid Apache Alias Path To Include Html Resources Like Css"