Skip to content

Does nginxconfig.io support subpath configuration for Wordpress? #421

Open

Description

@mehdiMj-ir

Information

https://whatismybrowser.com/w/5DDRK4Q

Help request

How to setup a Wordpress on a subpath with nginx?

Problem

I want Nginx configuration for Wordpress on a subpath, but didn't found any.

What I have tried

I tried to serve my blog located on /var/www/blog with this configuration but I couldn't succeed, (BTW my / is reverse peroxided and serve another application).

upstream php-srv {
  server unix:/run/php/php8.1-fpm.sock;
}

server {

  listen 443 ssl http2;
  #listen 443 ssl http2;
  ssl_certificate /etc/ssl/certs/domain.pem;
  ssl_certificate_key /etc/ssl/private/domain.key;
  server_name my.domain.com;
  #add_header 'Content-Security-Policy' 'upgrade-insecure-requests';

  location = /blog/robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location ~ /\. {
    deny all;
  }

  location /blog {
    try_files $uri $uri/ /blog/index.php?$args;
  }

    location ~ \.php$ {
      fastcgi_split_path_info ^(/blog)(/.*)$;
      include fastcgi_params;
      fastcgi_intercept_errors on; # off later #####
      fastcgi_pass php-srv;
  #    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param  SCRIPT_FILENAME /var/www/blog$fastcgi_script_name;
    }

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://127.0.0.1:1081$request_uri;
    include /etc/nginx/mime.types;
  }

}

server {
  listen 80;
  server_name my.domain.com;
  return 301 https://$host$request_uri;
}

Screenshots

Here is my first try with your app:

Screenshot_20230217_232134

Activity

  1. mehdiMj-ir commented on Feb 18, 2023

    @mehdiMj-ir
    Author
  2. TauqueerAhmad commented on Feb 22, 2023

    @TauqueerAhmad

    Clear the browser cache and cookies.
    Set your permalinks.
    Make a default .htaccess file.
    Set up a 301 redirect.
    Disable plugins and themes.
    Change and update the WordPress URL in the database.
    Fix the error on local servers.

  3. TauqueerAhmad commented on Feb 22, 2023

    @TauqueerAhmad

    I think this can help you out

  4. mehdiMj-ir commented on Feb 23, 2023

    @mehdiMj-ir
    Author

    Clear the browser cache and cookies. Set your permalinks. Make a default .htaccess file. Set up a 301 redirect. Disable plugins and themes. Change and update the WordPress URL in the database. Fix the error on local servers.

    Nginx doesn't support .htaccess, I use curl on my terminal so there is no browser or caching. BTW I already fix my path and address on wp database.

    Thanks for your comment but this doesn't resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions