CodeIginter, Mod_Rewrite on URLs and .htaccess
I'm unsure of which stackexchange site is best suited for this question as I could see it fitting in to several, especially depending on the ultimate answer.
The challenge I'm facing is that I've written a site using CodeIgniter. The site is a fairly simple company site. I've used CodeIginter to implement clean urls and the ability to expand the site in the future. There is also a simple blog and "gallery" which are both dynamic, driven by a database.
In my development environment, the site works great. On my staging space for the site (which drive my wordpress blog), the site also works.
The problem is as I'm trying to move the site to the production server, it stops working. I've been able to get the home page up (which uses the database and assets) so I'm fairly sure those are all working right. I've narrowed the problem down to either possible configuration issues or mod_rewrite issues.
The first thing I must bring up (but I'm unsure of how truly relevant this is) is the server uses CGI/FastCGI whereas my development and staging servers use "Apache 2.0 Handler". Will this difference cause me to need to modify my .htaccess file? I'm posting the base file that works in my development/staging environments here:
RewriteEngine on
RewriteCond $1 !^(index\.php|phpinfo\.php|images|robots\.txt|sitemap\.xml\.gz|sitemap\.xml|assets)
RewriteRule ^(.*)$ /index.php/$1 [L]
It's pretty straight forward.
When I attempt to run the site on the production server, with this .htaccess file, I get:
Can not exec the requested script [/ufs/websites/c/[redacted]/html/index.php/]: Not a directory
When I change my .htaccess to:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|robots\.txt|sitemap\.xml\.gz|sitemap\.xml|assets)
RewriteRule ^html/(.*)$ /index.php/$1 [L] #This WILL Present the home page correctly whereas it used to give an error
It'll give me the home page, but still none of the other pages work; instead I'll get either a 404 or a blank page.
For the time being, my guess at the problem is my RewriteRule but I'm really not entirely sure. It could be a setting in my config. I'll continue t开发者_如何学编程o poke around but I'm hoping someone will have experienced this in prior work that could help point me in the right direction (or best-yet) tell me what I'm doing wrong. :-)
Thanks all.
i don't know enough about the configuration, but a shot in the dark - since your changing the re-write rules is to also make sure that you have
$config['index_page'] = '';
set in
config.php
instead of
$config['index_page'] = 'index.php';
Well, you will see this question asked thousand times in the original forums. And this post have similar situation where every attemp to remove index.php can be nitpicky :) See the additional configuration you can try in that post.
精彩评论