Nginx Removes the index.php from URL
Posted
by
codeHead
on Server Fault
See other posts from Server Fault
or by codeHead
Published on 2014-08-23T08:29:47Z
Indexed on
2014/08/23
10:22 UTC
Read the original article
Hit count: 188
I have a codeigniter php application on nginx. It works as expected on Apache but after moving to nginx, I noticed that the index.php is automatically removed from the URL in all my links. Infact when I try using index.php it does not go to the desired URL but gets redirected to my default controller.
below is a coopy of my nginx.conf file.
server{
listen 80;
server_name mydomainname.com;
root /var/www/domain/current;
# index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log main;
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php ;
}
location ~* \.php {
fastcgi_pass backend;
include fastcgi.conf;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_read_timeout 500;
#fastcgi_param SCRIPT_FILENAME $document_root/index.php;
add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT";
add_header Cache-Control "no-cache, no-store, private, proxy-revalidate, must-revalidate, post-check=0, pre-check=0";
add_header Pragma no-cache;
add_header X-Served-By $hostname;
}
location ~* ^.+\.(css|js)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public";
}
# set expiration of assets to MAX for caching
location ~* \.(ico|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found on;
}
}
I need to use my URL With the index.php -- please help.
© Server Fault or respective owner