开发者

Preg_Replace Preg_Match to Redirect to WordPressDirectory

开发者 https://www.devze.com 2023-03-24 02:42 出处:网络
I have managed to solve the need to move the wp-admin directory of WordPress from: site_url() . wp-admin/

I have managed to solve the need to move the wp-admin directory of WordPress from:

site_url() . wp-admin/

to

MY_ADMIN_URL . wp-admin/

which is equivalent to

site_url() . /wp-content/plugins/myplugin/wp-admin/

Everything is working, after months of self-taught experimentation, and answers found on this forum. But there is one last thing I just cannot manage to do on my own.

I need to block access to every file in site_url() . / wp-admin/

and redirect each one to its equivalent in:

MY_ADMIN_URL . wp-admin/

but I cannot do it by identifying the wp-admin directory in a preg_match preg_replace, because the files are in a directory with thename wp-admin in both the original and new location, which 开发者_运维知识库I cannot change.

I also cannot hard code a url, because the actual uri of site_url(), and therefore MY_ADMIN_URL is obviosuly different for every installation.

To make matters worse, even if I could, I cannot fathom the boggling complexity of pregmatch.

Could someone please(!) help me come up with a piece of php code that would say:

if someone tries to go to

site_url() . wp-admin/filename.php

send them to

MY_ADMIN_URL . wp-admin/filename.php

Many many thanks in advance.

I genuinely looked right through the forums for an answer, and tried to cobble one together. But failed.


Consider using Lockdown WP Admin

This plugin will lockdown WP Admin. It can hide wp-admin and wp-login as well as add HTTP auth to the login system. It can change the login URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消