I am curious about altering the WordPress admin dashboard URL with out utilizing a third-party plugin.
In essence, I wish to rename the wp-admin
a part of URLs to one thing else, e.g. XX/secret/YY
as an alternative of XX/wp-admin/YY
.
Then, if customers strive accessing XX/wp-admin/YY
, they obtain a 404
not discovered error. They need to solely be capable of see the admin pages from XX/secret/YY
.
I’ve seen a number of sources on-line for altering the login path, however haven’t been capable of work out learn how to change how different administration pages are accessed.
wp-admin
is hard-corded into core recordsdata, so I’ve tried utilizing symlinking in order that recordsdata from inside wp-admin/
can nonetheless be included by WordPress. That is what I’ve achieved up to now:
- Added a rewrite rule to
XX/.htaccess
:
RewriteRule ^secret/(.*) wp-admin/$1?%{QUERY_STRING} [L]
- Outlined these constants in
XX/wp-config.php
:
outline('ADMIN_DIR', 'secret');
outline('SITECOOKIEPATH', '');
outline('COOKIEPATH', '');
- Used filters for these hooks:
add_filter('site_url', fn ($url) => str_replace('wp-admin', ADMIN_DIR, $url));
add_filter('admin_url', fn() => site_url(ADMIN_DIR));
add_filter('user_admin_url', fn() => site_url(ADMIN_DIR) . '/person');
- Created a symlink from
XX/wp-admin
toXX/secret
withln -s ./wp-admin ./secret
.
This ends in each XX/wp-admin/YY
and XX/secret/YY
being accessible. Nevertheless, including a rewrite rule to return 404
for XX/wp-admin
does so for each – I’m not sure on learn how to solely disguise XX/wp-admin
from customers.
I do know there could also be plugins to attain this, however I wish to discover ways to do that myself, both with Apache or WordPress alone.
Thanks prematurely!