I have enabled mod_rewrite and am using a .htaccess file to pass all requests through index.php.
If I visit the URL’s
http://localhost/mysite
http://localhost/mysite/abc
the page loads once.
However, if I add extra parts to the path, the page loads three times and my css files dont get included:
http://localhost/mysite/abc/xyz
http://localhost/mysite/abc/xyz/ttt
etc…
All cause the page to load three times. I can see this as I have a breakpoint set in index.php in Eclipse.
Here is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
# Block access to "hidden" directories whose names begin with a period.
# Files whose names begin with a period are protected by the FilesMatch directive
# above.
RewriteRule "(^|/)\." - [F]
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
Any ideas why the page is getting loaded multiple times and the css is missing?
I believe RewriteRule ^ index.php is the problem because of the space.
try this instead:
RewriteRule pattern substitution flags
pattern: Is requested file index.php
substitution: none (- means do not replace)
flag: L – last (don’t do any more)
Condition1: if the requested file does not exist
Condition2: If the requested file is not a directory
Apply next re-write rule
RewriteRule pattern substitution flags
pattern: anything
substitution: /index.php
flag: L – last (dont do any more)
IE jump to /index.php
so in summary:
If file requested is index.php OK (and stop processing any more rules)
otherwise
If file exists do it
If file is a directory go into that directory
otherwise
jump to index.php in root web directory