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
Answer: Well I found the problem, it turns out that even though I had disabled Multiviews in my httpd.conf file, they were still enabled in the /etc/apache2/sites-available/default and also the /etc/apache2/sites-available/default-ssl
This pair:
Treat the two URIs differently.
/sitemap.xml
does not match the RewriteCond and is passed through to the filesystem./sitemap
does match the RewriteCond and is rewritten to/index.php/sitemap
.The question is: What does your app do with that URI? If it finds the
sitemap.xml
file and serves it, that would explain the behaviour you are seeing.I really can't see any way those rewrites could serve
/sitemap.xml
when the request was/sitemap
. One way of verifying whether the request is running through your app or not is to create a new log file and set your app to append to it a line for each request that includes the date, the request URI and what it plans on serving (or what module it's running code from).You might have to elaborate a little more on the "extra slash" problem and maybe provide some examples. I don't quite understand the question.
With the comments, I understand now that the slash problem is here:
To get rid of the extra slash, you simply need to include it with the other part you are stripping out: (
index.php
):