Want more timely Centmin Mod News Updates?
Become a Member

Nginx Removing .php and .html/.htm extensions?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by tdubs, Jun 21, 2015.

  1. tdubs

    tdubs Member

    84
    12
    8
    Apr 10, 2015
    Ratings:
    +15
    Local Time:
    9:34 PM
    1.7.12
    10.0.17
    Hello,

    So I am wanting to clean up my URLs to my forum by removing the .php and .html/.htm extensions. I checked out Stack Overflow and found the best way to do so for an Nginx setup is to append the following /usr/local/nginx/conf/conf.d/mydomain.com.conf and include:

    Code:
    server {
    index index.html index.php;
    location /{
    try_files $uri $uri/ $uri.html $uri.php?$query_string;}
    location ~ \.php$ {
    try_files $uri =404;# add fastcgi_pass line here, depending if you use socket or port}}
    
    However, I know the config file is setup differently to an extent and I don't want to mess anything up. How can I go about properly doing this?


    Thanks! :)
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,935
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    9:34 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+