I'm having trouble configuring Codeigniter 2 with nginx. No problem with the landing page. But permalinks is not found.
404 Not Found
nginx
Htaccess:
IndexIgnore *
Options +FollowSymlinks
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
What should I do?
Many Thanks.
Nginx checks the case of the class loaded and the name of the file.
Ex: class name is Login. File name is login.php Result: 404.
Change the file name to Login.php and nginx would start working as expected.
Imp Note: Class name and file name's case should match.
To clarify, the .htaccess
file is for apache servers and therefore does nothing for your nginx server. You have to configure /etc/nginx/nginx.conf
file. Before that you should backup your current file cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
.
Then, try this one code:
# nginx configuration
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php/$1 break;
}
}
Disclaimer: I used this online service to get the code.
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.