directory - Serve WordPress site as root domain with WordPress files in subdirectory in nginx server

I'm trying to set up my WordPress install like as outlined in this article , with my project directory like so:wor

I'm trying to set up my WordPress install like as outlined in this article , with my project directory like so:

/wordpress/ # All my WordPress core files and folders here #
/wp-content/ #custom directory for my themes, plugins and uploads #
/wp-config.php

What I'd like to happen is to be able to go to my website root domain (in this case, "testsite.localhost"), and have all of my WordPress stuff work like a regular install, i.e., being able to go to testsite.localhost/wp-admin and having the admin area work like a normal install.

Here is my .conf file:

server {
    listen                          80;

    # substitute your web server's local URL with yours
    server_name                     testsite.localhost;

    index                           index.html index.php;
    client_max_body_size            40M;

    access_log              /usr/local/var/log/nginx/testsite.localhost.access.log;
    error_log               /usr/local/var/log/nginx/testsite.localhost.error.log;

    # substitute your web server's root folder with yours
    root                /Users/my.username/Development/local-wordpress;


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


    location ~ \.php$ {
        try_files                   $uri =404;
        fastcgi_index               index.php;
        fastcgi_param               SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_read_timeout        300;
        fastcgi_keep_conn           on;
        include                     /usr/local/etc/nginx/fastcgi_params;
    # Php-fpm is bound to port 9071
        fastcgi_pass                127.0.0.1:9071;
        index                       index.html index.php;  
    }
}

Here is my wp-config.php:

<?php

/* MySQL settings */
define( 'DB_NAME',     'localwp' );
define( 'DB_USER',     'root' );
define( 'DB_PASSWORD', 'somepassword' );
define( 'DB_HOST',     'localhost' );
define( 'DB_CHARSET',  'utf8mb4' );


/* MySQL database table prefix. */
$table_prefix = 'wp_';


/* WordPress Cache */
define( 'WP_CACHE', true );


/* Updates */
define( 'DISALLOW_FILE_MODS', true );
define( 'DISALLOW_FILE_EDIT', true );

/* Custom WordPress URL. */

define('WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content');


/* Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/* Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

When I run nginx locally, I'm able to access the front-end of my site at testsite.localhost. However, when I try to go to testsite.localhost/wp-admin, it redirects me to testsite.localhost/wordpress/wp-admin, but still shows the homepage of my site.

What I'd like to do is be able to access testsite.localhost/wp-admin like a normal WordPress install, without any redirecting or URL rewriting.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744713188a4589463.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信