I'm experiencing a similar issue with a 404 error message. I'm using CI 2.0.2 and I have a basic shared hosting with 1and1, and my .htaccess located in my website root (/mywebsite/.htaccess) directory and it looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
In my config.php file I have the following:
<?php
$config['base_url'] = 'http://mywebsite.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
It doesn't matter what I do I keep getting the 404 page not found error :http://d.pr/F2KR
I have spent several hours on looking for a solution to this problem and have not been able to fix it.
Any Suggestions, tips, or an actual answer to this question is greatly appreciated.
UPDATE 1: I called 1and1 and they told me that it must be a problem with the index.php since that 404 error message is generated by CodeIgniter and not the server. are there other configuration values that I should be looking at?
UPDATE 2: I found out that there is a case sensitive issue (this is odd since both localhost and server are UNIX/LINUX respectively), if the controller class is called Login, then the path needs to be mysite.com/Login/ it cannot be mysite.com/login/. I'm still not sure how this issue will be resolved, I don't want to re-write a bunch of paths.
UPDATE 3 (RESOLVED): As stated on update 2, the issue was not the .htaccess, but the naming scheme of my models and controllers, more specifically the file names. Apparently on my Mac (dev machine) I can have models called User.php or Login.php and will make no difference if I use upper or lower case in the URL, but as soon as I uploaded my code into 1and1, I kept getting the CI "404 not found" error message. My particular solution to the problem was to change all the models and controllers file names to lowercase as sugg开发者_运维技巧ested on this post http://codeigniter.com/forums/viewthread/129013/#636849.
RewriteEngine On
RewriteBase /
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 ^(.*)$ index.php?/$1 [L]
Try modifying the first <if>
to the code above, works for my codeigniter setup.
Not sure about the AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
...
I agree w/Chris, to be sure you have mod_rewrite enabled you can try to change the 404 page:
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
to something else like a dummy page
<IfModule !mod_rewrite.c>
ErrorDocument 404 my_dummy_page.html
</IfModule>
if you begin to havin the new 404 dummy page it's because you don't have mod_rewrite enabled.
I use this htaccess on my 1and1 and my CI2 runs fine. Its located in the CI base folder. Also make sure that your .htaccess has a .(dot) in the name, generally windows removes that dot.
Options -Indexes
DirectoryIndex index.php
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.in
RewriteRule (.*) http://www.example.in/$1 [R=301,L]
精彩评论