{"id":1509,"date":"2017-05-25T20:13:29","date_gmt":"2017-05-25T14:43:29","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1509"},"modified":"2017-05-25T20:13:29","modified_gmt":"2017-05-25T14:43:29","slug":"adding-automatic-extension-php-nginx","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/adding-automatic-extension-php-nginx\/","title":{"rendered":"Adding automatic extension (php) on nginx"},"content":{"rendered":"<h3>Adding automatic extension (php) on nginx<\/h3>\n<p><strong>Date Posted:25-05-2017<\/strong><\/p>\n<p>Well, normally no one likes to expose the language written on their website. On apache, we will use .htaccess to autoadd the extension. In this post, we will show on how to autoadd the extension on nginx configuration.<\/p>\n<p>Incase, if nginx is not installed by default follow the below post to install nginx on the server.<\/p>\n<ul>\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-mariadb-ubuntu-16-04-1\/\">Install Nginx on Ubuntu<\/a><\/li>\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-fpm-mariadb-on-centos-7\/\">Install Nginx on\u00a0Centos 7<\/a><\/li>\n<\/ul>\n<h3>Implementation:<\/h3>\n<p>Open the nginx configuration and add the below lines to autoadd extension. \u00a0Incase, if we want to particular domain, we need to update corresponding domain configuration.<\/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.html $uri\/ @extensionless-php;\r\nindex index.html index.htm index.php;\r\n}\r\nlocation @extensionless-php {\r\nrewrite ^(.*)$ $1.php last;\r\n}<\/pre>\n<p>Check the nginx syntax error.<\/p>\n<p><code>nginx -t<\/code><\/p>\n<p>Restart the nginx service for the changes come into effect.<\/p>\n<p><code>systemctl restart nginx<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding automatic extension (php) on nginx Date Posted:25-05-2017 Well, normally no one likes to expose the language written on their [&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,273],"class_list":["post-1509","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-codeigniter","tag-nginx","tag-php","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-ol","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1509","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=1509"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}