I changed my Wordpress directory structure quite a bit. Here's what I have:
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']);
define('WP_CONTENT_DIR', dirname(__FILE__) . '/content');
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/content');
So I have a content directory which contains my Plugins and Themes. And then I have a wordpress directory which contains the core WP files, minus the wp-content folder.
With this new structure, I have to access the WP backend with this URL: http://site.dev/wordpress/wp-admin
Is there a way I can change it so I can just access it like so: http://site.dev/wp-admin
I don't want wordpress to be in the URL. Would this be an htaccess update I need to make, or is there a setting I can use in my wp-config.php file?
Finally found a way to do it without a plugin AND WITHOUT MODIFYING WP CORE (all tutorials suggests to do so for some weird reason).
1- Copy
wp-login.php
and rename it tonew-secret-url.php
(on your root directory)2- Open
new-secret-url.php
file and perform a search/replace ofwp-login.php
tonew-secret-url.php
3- Add the following code to your functions.php:
4- This only works if you're not using any other frontend login forms, if you do, you can change:
is_user_logged_in()
to possibly!current_user_can( 'subscriber' )
(or the role given in the frontend login logic)5- Not sure if ajax calls works with the above, please let me know if you've tried it
All I did was moved
/wp-admin
folder ( inside ofpublic_html/wordpress
) intopublic_html
and I double checked to make sure it was going to work by renaming my WordPress folder ( I usedwordpress_test
, you can use anything ) and went to my siteexample.com/wp-admin
- it worked just the same as if I went toexample.com/wordpress/wp-admin
.The only thing which is quite tricky is changing the
wp-admin
to something else , due to the fact the WP had coded thewp-admin
throughout numerous files. Just simply changing the name causes php and other errors. Simple plugin I find will fix that easily.Note: I didn't have to make any coding to do this. I had to change some code around for the
wp-admin
, because the plugin didn't do what I wanted.I played around with this and there is a much simpler way to do this all in this one simple function below without having to muck around with anything else (create unnecessary folders, redirects, pages, etc.).
This is very helpful topic. I made some little correction in the function and this is my version:
Mainly for redirecting of
wp-admin
.And most important part:
To updates
.htaccess
rule.There is one other way that will ensure quite better tactic to your secured wp-admin.
As well having own wp-admin name as perhaps: "worksersneeded/"
I did it to one of my sites, ended up in miracle where the probed SSL site was displaying different towards my site from different geo locations.
You will have to download a tool called Notepad ++: https://notepad-plus-plus.org/download/
Unless you will be doing to much work on each of the files in the directory.
After then you need to extract the WordPress into a folder.
Then edit all files in the directory while searching after wp-admin. Then replace all the files with your the name: "workersneeded" or your own name.
Like in notepad enter "search in files" to "find what": wp-admin/
And in "replace with": workersneeded/
Then replace all files.
You need to put into wp-config.php this line as well to monitor all problems:
After you overwritten most in the WordPress directory and your wp-admin has now the name "workersneeded" you will most likely encounter slight problems with some of your WordPress plugins or themes.
That is why you will need to log them into the error_log.txt file.
After finding the errors in the file. You will most likely need to edit the .php file which still tries to connect to wp-admin. That way you can replace the file information of wp-admin to your administration folder.
You can again download your plugins and replace the same procedure as above with notepad++. That way you can make all plugins available with the new folder name.
Then upload the folder of each plugin into your wp-content directory with wp file manager plugin.
Be aware that your WordPress can't be auto-updated or updated doing so, even doing re-installation of your WordPress. You will have to do these replacements each time.
This was done with 4.9.8 version of WordPress as well as the newest 5.0.3
With 5.0.3 you get more errors into the error_log.txt file. Unknown why.
Here's an article from wordpress's site.
Add constant to wp-config.php
Add below filter to functions.php
Add below line to .htaccess file