title: Wordpress on Ubuntu - "File not Found" for home.php - Trying to Redirect to Root Folder
body: <p>I recently did a one-click installation on a Ubuntu server set up via Vultr. There is a PHP URL path (site.com/home.php) that I want to 301 redirect to the root folder (site.com/) but nothign has worked so far. Here are a few things I tried...</p>
  <ol>
  <li>Set up .htacess file with mod rewrite rule (seems to ignore this)</li>
  <li>Looked into nginx config files. I have three.</li>
  </ol>
  <pre><code>cockpit.conf
  wordpress_http.conf
  wordpress_https.conf
  </code></pre>
  <p>I tried updating a few things based on other threads but nothing worked (I'm a beginner with server configurations so I might have done the wrong thing too).
  The content of each config file is:</p>
  <p><strong>cockpit.conf</strong></p>
  <pre><code>server {
      listen 9080 ssl;
      server_name _;
      ssl_certificate /etc/nginx/ssl/server.crt;
      ssl_certificate_key /etc/nginx/ssl/server.key;
      # set max upload size
      client_max_body_size 2G;
      fastcgi_buffers 64 4K;
      access_log /var/log/nginx/cockpit_access.log combined;
      error_log /var/log/nginx/cockpit_error.log;
      server_tokens off;
      location / {
          # Required to proxy the connection to Cockpit
          proxy_pass https://127.0.0.1:9090;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-Proto $scheme;
          # Required for web sockets to function
          proxy_http_version 1.1;
          proxy_buffering off;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection &quot;upgrade&quot;;
          # Pass ETag header from Cockpit to clients.
          # See: https://github.com/cockpit-project/cockpit/issues/5239
          gzip off;
      }
  }
  </code></pre>
  <p><strong>wordpress_http.conf</strong></p>
  <pre><code>
  upstream php-handler-http {
  server 127.0.0.1:9000;
  }
  server {
  listen 80 default_server;
  server_name _;
  #server_name wordpress.example.com;
  
  root /var/www/html/;
  index index.php;
  
  # set max upload size
  client_max_body_size 2G;
  fastcgi_buffers 64 4K;
  
  access_log /var/log/nginx/wordpress_http_access.log combined;
  error_log /var/log/nginx/wordpress_http_error.log;
  
  server_tokens off;
  
  location = /favicon.ico {
  log_not_found off;
  access_log off;
  }
  
  location = /robots.txt {
  allow all;
  log_not_found off;
  access_log off;
  }
  
  location / {
  try_files $uri $uri/ /index.php?$args ;
  }
  
  # protected area (XHProf)
  location ^~ /xhprof/xhprof_html/ {
  auth_basic &quot;Restricted&quot;;
  auth_basic_user_file /etc/nginx/htpasswd/xhprof;
  
  location ~ \.php(?:$|/) {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PHP_FLAG &quot;session.auto_start=off \n mbstring.encoding_translation=off&quot;;
  fastcgi_param PHP_VALUE &quot;assert.active=0 \n mbstring.http_input=pass \n mbstring.http_output=pass&quot;;
  fastcgi_pass php-handler-http ;
  fastcgi_read_timeout 60s;
  }
  }
  
  # protected area (phpmyadmin)
  location ^~ /mysqladmin/ {
  auth_basic &quot;Restricted&quot;;
  auth_basic_user_file /etc/nginx/htpasswd/phpmyadmin;
  
  location ~ \.php(?:$|/) {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PHP_FLAG &quot;session.auto_start=off \n mbstring.encoding_translation=off&quot;;
  fastcgi_param PHP_VALUE &quot;assert.active=0 \n mbstring.http_input=pass \n mbstring.http_output=pass&quot;;
  fastcgi_pass php-handler-http ;
  fastcgi_read_timeout 60s;
  }
  }
  
  location ^~ /wp-admin/install.php {
  auth_basic &quot;Restricted&quot;;
  auth_basic_user_file /etc/nginx/htpasswd/wpadmin;
  
  location ~* \.(htaccess|htpasswd) {
  deny all;
  }
  
  location ~ \.php(?:$|/) {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PHP_VALUE &quot;auto_prepend_file=/var/www/html/xhprof/external/header.php&quot;;
  fastcgi_pass php-handler-http;
  fastcgi_read_timeout 60s;
  }
  }
  
  location ~* \.(htaccess|htpasswd) {
  deny all;
  }
  
  location ~* \.(?:ini|conf|txt)$ {
  deny all;
  }
  
  location ~ \.php(?:$|/) {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PHP_VALUE &quot;auto_prepend_file=/var/www/html/xhprof/external/header.php&quot;;
  fastcgi_pass php-handler-http;
  fastcgi_read_timeout 60s;
  }
  
  # set long EXPIRES header on static assets
  location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
  expires 30d;
  access_log off;
  }
  
  }
  </code></pre>
  <p>wordpress_https.conf</p>
  <pre><code>
  upstream php-handler-https {
      server 127.0.0.1:9000;
  }
  
  server {
      listen 443 ssl default_server;
      server_name _;
      #server_name wordpress.example.com;
  
      ssl_certificate /etc/nginx/ssl/server.crt;
      ssl_certificate_key /etc/nginx/ssl/server.key;
  
      root /var/www/html/;
      index index.php;
  
      # set max upload size
      client_max_body_size 2G;
      fastcgi_buffers 64 4K;
  
      access_log /var/log/nginx/wordpress_https_access.log combined;
      error_log /var/log/nginx/wordpress_https_error.log;
  
      server_tokens off;
  
      location = /favicon.ico {
          log_not_found off;
          access_log off;
      }
  
      location = /robots.txt {
          allow all;
          log_not_found off;
          access_log off;
      }
  
      location / {
          try_files $uri $uri/ /index.php?$args ;
      }
  
      # protected area (XHProf)
      location ^~ /xhprof/xhprof_html/ {
          auth_basic &quot;Restricted&quot;;
          auth_basic_user_file /etc/nginx/htpasswd/xhprof;
  
          location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PHP_FLAG &quot;session.auto_start=off \n mbstring.encoding_translation=off&quot;;
            fastcgi_param PHP_VALUE &quot;assert.active=0 \n mbstring.http_input=pass \n mbstring.http_output=pass&quot;;
            fastcgi_pass php-handler-http ;
            fastcgi_read_timeout 60s;
          }
      }
  
      # protected area (phpmyadmin)
      location ^~ /mysqladmin/ {
          auth_basic &quot;Restricted&quot;;
          auth_basic_user_file /etc/nginx/htpasswd/phpmyadmin;
  
          location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PHP_FLAG &quot;session.auto_start=off \n mbstring.encoding_translation=off&quot;;
            fastcgi_param PHP_VALUE &quot;assert.active=0 \n mbstring.http_input=pass \n mbstring.http_output=pass&quot;;
            fastcgi_pass php-handler-http ;
            fastcgi_read_timeout 60s;
          }
      }
  
      location ^~ /wp-admin/install.php {
          auth_basic &quot;Restricted&quot;;
          auth_basic_user_file /etc/nginx/htpasswd/wpadmin;
  
          location ~* \.(htaccess|htpasswd) {
              deny all;
          }
  
          location ~ \.php(?:$|/) {
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_param PATH_INFO $fastcgi_path_info;
              fastcgi_param HTTPS on;
              fastcgi_param PHP_VALUE &quot;auto_prepend_file=/var/www/html/xhprof/external/header.php&quot;;
              fastcgi_pass php-handler-https;
              fastcgi_read_timeout 60s;
          }
      }
  
      location ~* \.(htaccess|htpasswd) {
          deny all;
      }
  
      location ~* \.(?:ini|conf|txt)$ {
          deny all;
      }
  
      location ~ \.php(?:$|/) {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
          fastcgi_param HTTPS on;
          fastcgi_param PHP_VALUE &quot;auto_prepend_file=/var/www/html/xhprof/external/header.php&quot;;
          fastcgi_pass php-handler-https;
          fastcgi_read_timeout 60s;
      }
  
      # set long EXPIRES header on static assets
      location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
          expires 30d;
          access_log off;
      }
  
  }
  
  
  server {
      listen 443 ssl ;
      server_name www.gardenfreshsalsa.com gardenfreshsalsa.com; # managed by Certbot
      #server_name wordpress.example.com;
      ssl_certificate /etc/letsencrypt/live/gardenfreshsalsa.com/fullchain.pem; # managed by Certbot
      ssl_certificate_key /etc/letsencrypt/live/gardenfreshsalsa.com/privkey.pem; # managed by Certbot
  
      root /var/www/html/;
      index index.php;
  
      # set max upload size
      client_max_body_size 2G;
      fastcgi_buffers 64 4K;
  
      access_log /var/log/nginx/wordpress_https_access.log combined;
      error_log /var/log/nginx/wordpress_https_error.log;
  
      server_tokens off;
  
      location = /favicon.ico {
          log_not_found off;
          access_log off;
      }
  
      location = /robots.txt {
          allow all;
          log_not_found off;
          access_log off;
      }
  
      location / {
          try_files $uri $uri/ /index.php?$args ;
      }
  
      # protected area (XHProf)
      location ^~ /xhprof/xhprof_html/ {
          auth_basic &quot;Restricted&quot;;
          auth_basic_user_file /etc/nginx/htpasswd/xhprof;
  
          location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PHP_FLAG &quot;session.auto_start=off \n mbstring.encoding_translation=off&quot;;
            fastcgi_param PHP_VALUE &quot;assert.active=0 \n mbstring.http_input=pass \n mbstring.http_output=pass&quot;;
            fastcgi_pass php-handler-http ;
            fastcgi_read_timeout 60s;
          }
      }
  
      # protected area (phpmyadmin)
      location ^~ /mysqladmin/ {
          auth_basic &quot;Restricted&quot;;
          auth_basic_user_file /etc/nginx/htpasswd/phpmyadmin;
  
          location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PHP_FLAG &quot;session.auto_start=off \n mbstring.encoding_translation=off&quot;;
            fastcgi_param PHP_VALUE &quot;assert.active=0 \n mbstring.http_input=pass \n mbstring.http_output=pass&quot;;
            fastcgi_pass php-handler-http ;
            fastcgi_read_timeout 60s;
          }
      }
  
      location ^~ /wp-admin/install.php {
          auth_basic &quot;Restricted&quot;;
          auth_basic_user_file /etc/nginx/htpasswd/wpadmin;
  
          location ~* \.(htaccess|htpasswd) {
              deny all;
          }
  
          location ~ \.php(?:$|/) {
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_param PATH_INFO $fastcgi_path_info;
              fastcgi_param HTTPS on;
              fastcgi_param PHP_VALUE &quot;auto_prepend_file=/var/www/html/xhprof/external/header.php&quot;;
              fastcgi_pass php-handler-https;
              fastcgi_read_timeout 60s;
          }
      }
  
      location ~* \.(htaccess|htpasswd) {
          deny all;
      }
  
      location ~* \.(?:ini|conf|txt)$ {
          deny all;
      }
  
      location ~ \.php(?:$|/) {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
          fastcgi_param HTTPS on;
          fastcgi_param PHP_VALUE &quot;auto_prepend_file=/var/www/html/xhprof/external/header.php&quot;;
          fastcgi_pass php-handler-https;
          fastcgi_read_timeout 60s;
      }
  
      # set long EXPIRES header on static assets
      location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
          expires 30d;
          access_log off;
      }
  }
  </code></pre>
  <p>Would someone be able to point me in the right direction?</p>
  <p><strong>Desired Result</strong></p>
  <p><a href="https://www.abcde.org/home.php" rel="nofollow noreferrer">https://www.abcde.org/home.php</a> -&gt; 301 redirects <a href="https://www.abcde.org/" rel="nofollow noreferrer">https://www.abcde.org/</a></p>