Nginx - wordpress in a subdirectory, what data should be passed?

后端 未结 3 1991
心在旅途
心在旅途 2020-12-22 23:09

I\'ve tried so many different things. The point I\'m at right now is this:

location ^~ /wordpress {
    alias /var/www/example.com/wordpress;
    index index         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 23:27

    I had the same problem and this is what fixed it for me:

    1. Open the NGINX configuration file for your site. Inside of the server block, add the path to your root directory and set the priority order for files:

      root /mnt/www/www.domainname.com;
      index  index.php index.html index.htm;
      
    2. Create an empty location block before all your other location blocks:

      location /latest {
      # Nothing in here; this is to avoid redirecting for this location
      }
      
    3. Commend out the root directory in your location / block and add the redirection so it looks like this:

      location / {
      # root   /mnt/www/www.domainname.com;
      index  index.php index.html index.htm;
      rewrite ^/(.*)$ http://www.domainname.com/latest/$1 redirect;
      }
      
    4. Make sure that your location ~ .php$ block points its root to

      root /mnt/www/www.domainname.com;
      

    This fixed it for me.

提交回复
热议问题