Mod_rewrite is ignoring the extension of a file
- by ngl5000
This is my entire mod_rewrite condition:
<IfModule mod_rewrite.c>
<Directory /var/www/>
Options FollowSymLinks -Multiviews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
# force www. (also does the IP thing)
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^mysite\.com [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
RewriteCond %{THE_REQUEST} /index\.(php|html)
RewriteRule (.*)index\.(php|html)(.*)$ /$1$3 [r=301,L]
RewriteCond %{REQUEST_URI} !^(/index\.php|/assets|/robots\.txt|/sitemap\.xml|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
# Block access to "hidden" directories or files whose names begin with a period. This
# includes directories used by version control systems such as Subversion or Git.
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</Directory>
</IfModule>
It is suppose to allow only access to mysite.com(/index.php|/assets|/robots.txt|/sitemap.xml|/favicon.ico)
The error was noticed with: mysite.com/sitemap vs mysite.com/sitemap.xml
Both of these addresses are resolving to the xml file while the first url should be resolving to mysite.com/index.php/sitemap *
For some reason mod_rewrite is completely ignoring the lack of an extension. It sounded like a Multiviews problem to me so I disabled Multiviews and it is still going on.
***And then a different rule will eventually take the index.php out, I am having another problem with an extra '/' being left behind when this happens.
This httpd file is setting up for my codeigniter php framework