Hosting CodeIgniter inside a sub directory with Nginx


 

As I mentioned in my previous post, I had been setting up an old Codeigniter web app today in my local machine. This app was hosted with the Apache web server and it was running on PHP 5.6.


I tried to put this in a VM in my local machine using Vagrant. However, I faced some issues with this setup as I wanted to make it run with Nginx instead of Apache, and that too, inside a sub directory. The main problem I had was with the URL rewrites. In Apache, I was able to write an httaccess file and that would simply handle the rewrites. 


However after some trial and error efforts, it turned out that it was really easy. Even easier than I actually thought. All I had to do was set the correct paths in the nginx config.

 

My CI app as residing inside a directory called 'admin'. So in my nginx host config file, I provided a location block as below.

 

location /admin {
        try_files $uri $uri/ /admin/index.php?/$query_string;
}


and voila, it started working. 

 

I thought of adding this to my blog as a note to myself. Anyway, If you ever come across this post, and have any issues, feel free to leave a comment.

11 comments :

  1. this information So i am glad to www.offshoreservers.net
    show that I have a very excellent uncanny feeling
    I discovered just what I needed.

    ReplyDelete
  2. It might be extremely useful and Honey well Gent Fire alarm system Pakistan useful for me and my friends.

    ReplyDelete
  3. Thanks for the blog it is very helpful. If you are looking for a services of Fantastic Door Refinish, kindly check Fantastic Door Refinish Pearland

    ReplyDelete
  4. Door Refinishing made Simple Are your doors suffering from exposure to weather or just normal wear and tear Contact Us For a Quote!
    Door Refinishing

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hey, Ben Anderson this side. I am working in a ticket managing department under the American airlines. If you want to know about the american airlines manage booking then you can reach there by visiting the official website and you can submit your request for the changes there.

    ReplyDelete
  8. Thanks For Sharing This Useful information it help me a lot you can explain content in depth BestWebHosting

    ReplyDelete
  9. Thanks for sharing this amazing and informative post. keep sharing with us.

    ReplyDelete
  10. I confronted a few issues with this arrangement as I needed to make it run with Nginx rather than Apache, and that as well, inside a sub registry. The primary issue I had was with the URL reworks.

    ReplyDelete
  11. I spent a few hours searching for this solution. Even AI failed to give an adequate answer. That finally is so easy. Thanks a lot

    ReplyDelete