简体   繁体   中英

CodeIgniter 404 Page Not Found htaccess

I got 404 Page Not Found when I tried to access my file without the index.php. this is my .htaccess.

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /HR/
# If your project is in server root then should be: RewriteBase/
# If project is in folder then it should be: RewriteBase /folder_name/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^.(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

I have been using this one

Place this in main directory out side of application folder.

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Also make sure if your using codeigniter 3 that the first letter of class and file name must be uppercase only.

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Note: .htaccess vary depending on server. In some server (eg: Godaddy) need to use the following .htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM