Setting up nginx http server was not so bad I thought. Setting up Codeigniter on my server was easy (Just follow the instruction in their documentation).
However, codeigniter redirect was not working except the one that is set up in $route['default_controller'] = “blahblah”;…
If you encounter the same problem as I struggled from, find the config.php from /application/config/ directory and search for “$config['uri_protocol'] = “blahblah”;
When you look at its documentation carefully, it says :
If your links do not seem to work, try one of the other delicious flavors:
So I changed it to “REQUEST_URI” and my Codeigniter’s rewrite rule started working!
If you wonder what my conf file looks like, here it is:
server {
listen 80;
server_name domain.com;
location ~ /\. {
deny all;
}
rewrite ^/(.*) http://www.domain.com/$1 permanent;
}
server {
listen 80;
server_name www.domain.com;
access_log /path/to/your/app/log/access.log;
error_log /path/to/your/app/log/error.log;
location ~ /\. {
deny all;
}
location / {
index index.php;
root /path/to/your/app/public;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ /index.php/ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/your/app/public/$fastcgi_script_name;
}
}





0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.