Having developed many a site with CodeIgniter, I usually include a .htaccess file to remove the 'index.php' component of the URL.
Never had a problem before.
My new site uses my 'standard' .htaccess file
.htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|uploads)
RewriteRule ^(.*)$ /index.php/$1 [L]
The rewrite rule is supposed to take any request that doesn't start in 'index.php' or 'uploads'and append it the end of 'index.php' - for example:
1: http://mysite.com/controller --> http://mysite.com/index.php/controller
2: http://mysite.com/anothercontroller --> http://mysite.com/index.php/anothercontroller
It works as expected on my development server (MAMP), however, I am trying to upload it to a server using: Apache2 with virtual hosts controlled by VirtualMin on Debian Lenny
mod_rewrite is up and running on this server as simple rules work such as:
RewriteRule ^old.html$ new.html
The apache error logs don't seem to show up anything untoward.
Any ideas on why this will not work on the apache2/debian/virtualmin server (or how to turn on rewrite logs for virtual hosts using VirtualMin so I can analyse further?)
Cheers :)
EDIT I managed to figure out how to increase error level to debug in VirtualMin - here's the output - seems I'm getting recursion ... ??
[Sat Jan 15 09:11:52 2011] [error] [client 110.174.208.166] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat Jan 15 09:11:52 2011] [debug] core.c(3063): [client 110.174.208.166] r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/inde开发者_开发问答x.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /
Virtualmin configures a standard Apache. There is nothing different about rewrite rules on a Virtualmin system from any other Apache configuration. The web server in a Virtualmin system is Apache. So, don't look for a "Virtualmin solution" to your problem; this problem isn't related to Virtualmin (though Virtualmin does have some UI tools for editing and modifying htaccess files and rewrite rules and such, you don't have to use them, and they aren't doing anything magical or different from what you're doing manually in the htaccess file).
Compare your actual httpd.conf on your development system vs. your production system...something is different. Your OS is more likely to be the source of differences in default configuration.
Check to be sure htaccess allows all the directives you're trying to use, for instance. It is possible to limit what capabilities htaccess files can configure, and I suspect the Debian default configuration is much more strict by default than MAMP. You'd probably see some errors in the error.log of the virtual host in question, or in the main error.log if this is the case.
Have you considered using FallbackResource?
OK... so many hours later I come to my solution.
Firstly, I wanted to prove to myself that it wasn't Debian so I
- fresh installed a minimal copy of Debian on a spare VPS I had
- installed Apache2
- enabled rewrite module and allowed override
- copied .htaccess file and php files
- presto! it worked without issue!!
Ok - so it wasn't Debian + Apache - I then set up virtual hosts on the VPS under Apache - still worked beautifully
Back to VirtualMin + Apache + Debian
- backed up the virtual host .conf file
- copied across the working Debian + Apache virtual host file
- presto! it worked.
Ok... so it had something to do with the way VirtualMin was 'writing' the virtual host .conf file (/etc/apache2/sites-enabled/example-domain.com.conf)
Painstakingly commenting out the file section by section, I found the offending lines under the <Directory /home/example-domain/public_html>
section:
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/epeau/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/epeau/fcgi-bin/php5.fcgi .php5
Commenting out these four lines, and everything worked as expected. For some reason it appears that using FastCGI causes the problems.
精彩评论