Wood Chen

Separating the WordPress Admin Area from the Frontend

0 comments241 views191 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

Change the WordPress Address and Site Address

There are two URL values under WordPress Admin -> Settings -> General, as shown below:

As shown above, WordPress lets you set different addresses for the admin area and the frontend. WordPress Address (URL) is where the WordPress application runs, while Site Address (URL) is the address visitors use to access the site. (You can customize root.domain.com.) After this change, the admin login address becomes: root.woodchen.ink/wp-admin. Since the domain WordPress runs on has changed, you also need to update the Cookie domain in wp-config.php; otherwise, you will not be able to log in to the admin area. Add the following line to wp-config.php:

define('COOKIE_DOMAIN', '.woodchen.ink');

Note the leading dot: .woodchen.ink sets the Cookie domain to *.woodchen.ink. Changing the WordPress Address also changes the paths for all plugins, themes, and uploaded files. All paths previously under woodchen.ink/wp-content/* become root.woodchen.ink/wp-content/*, so you also need to specify the wp-content path. Add the following line to wp-config.php:

//Set the wp-content directory to its full URI (without a trailing slash), for example
define( 'WP_CONTENT_URL', 'https://woodchen.ink/wp-content');

This keeps all paths unchanged while separating the admin area from the frontend.

Last updated 2024-01-14

Related posts

Comments 0