{"id":1511,"date":"2017-05-25T17:11:58","date_gmt":"2017-05-25T11:41:58","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1511"},"modified":"2017-05-25T17:11:58","modified_gmt":"2017-05-25T11:41:58","slug":"codeigniter-404-error-nginx","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/codeigniter-404-error-nginx\/","title":{"rendered":"Codeigniter 404 error on nginx"},"content":{"rendered":"<h3>Codeigniter 404 error on nginx<\/h3>\n<p><strong>Date Posted:24-05-2017<\/strong><\/p>\n<p>Recently, we deployed a\u00a0codeigniter application on one of our server and found that it shows 404 error when we try to access the custom urls(such as domain.tld\/login, domain.tld\/admin, domain.tld\/dashboard). The same application works fine on Apache webserver.<\/p>\n<p>After a long research, we found that it was due to redirection issue on nginx configuration.<\/p>\n<h4><strong>Resolution:<\/strong><\/h4>\n<p>This post assumes that nginx is running and we are deploying the codeigniter on the documentroot.<\/p>\n<p>Open the nginx configuration and add the below lines which applies to all the \/ directory.<\/p>\n<p><code>vi \/etc\/nginx\/sites-enabled\/default<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">location \/ {\r\ntry_files $uri $uri\/ \/index.php;\r\n}<\/pre>\n<p>Incase, if there is a separate configuration for domain, then we need to edit the configuration accordingly\/.<\/p>\n<p>Verify the nginx syntax<\/p>\n<p><code>nginx -t<\/code><\/p>\n<p>Restart the nginx service.<\/p>\n<p><code>systemctl restart nginx<\/code><\/p>\n<h4>Additional Information:<\/h4>\n<p>If we deploy the application on the subdirectory (say for example \/directory) then we need to apply the below redirection rule.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">location \/directory1 {\r\ntry_files $uri $uri\/ \/directory1\/index.php;\r\n}<\/pre>\n<p>Verify the syntax and restart the nginx service.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Codeigniter 404 error on nginx Date Posted:24-05-2017 Recently, we deployed a\u00a0codeigniter application on one of our server and found that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[341,271],"class_list":["post-1511","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-codeigniter","tag-nginx","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-on","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1511"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1511\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}