Forum Moderators: phranque
My test local site folder structure:
d:\sites\example\.
d:\sites\example\css\.
d:\sites\example\js\.
d:\sites\example\images\.
...
In the browser:
[localhost...]
.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule> If I link stuff (css, js, jpg, ...) such as:
<link rel="stylesheet" href="css/style.css" type="text/css" />
When .htaccess is in place, the resource is not found, the css is not loaded. The whole site seems to take forever to load, I think Apache has entered in a loading loop. I see raw text, without style applied, no images too.
Instead if I use a url like:
<link rel="stylesheet" href="/example/css/style.css" type="text/css" />
It works. (If I deactivate/move/rename away .htaccess, all works perfectly even without the /example/ prefix)
Is there a particular reason to explain this behaviour? Why should I use complete url such as /example/.../resource.ext ? I'm not a mod_rewrite expert, so the issue could be in there.
Thanks for reading so far.
/robots.txt
custom error pages
/sitemap.xml
/w3c/p3p.xml
/labels.rdf (or .xml)
images & media files
external css
external JavaScript files
.pdf documents (or others)
search engine tools "authorization key" files
Using an explicit exclusion list can be far more efficient than simply checking to see if the requested URL resolves to an existing file or directory. It can also greatly reduce the amount of error handling that the script needs to do, because as it stands now, the script is solely responsible for determining whether to return a 200-OK status response, a 301, 302, or 303 redirect, a 404-Not Found, or a 410-Gone.
The explicit exclusion list prevents the server having to call the OS to go check the filesystem twice for each and every HTTP request made to your server. This can significantly impact server performance on a busy site -- or on a site that shares a server with other busy sites.
Jim