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?
Go to cPanel > Databases section > phpMyAdmin menu: 3. Click on '+' next to your cPanel username to expand the list of the databases, locate the database for the WordPress website and click on it. Then, select wp_options table (wp_ is the database prefix and it can be different for your installation):
The simplest way to find your WordPress login URL is to add /admin to the end of your site URL. For example, if your WordPress site is www.mywebsite.com , you can access your login page by visiting www.mywebsite.com/admin .
By default every WordPress installation has two login URLs: yourdomain.com/wp-admin.php and yourdomain.com/wp-login.php.
Here's an article from wordpress's site.
http://wordpress.org/support/topic/how-to-change-the-admin-url-or-wp-admin-to-secure-login
Add constant to wp-config.php
define('WP_ADMIN_DIR', 'secret-folder');
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);
Add below filter to functions.php
add_filter('site_url', 'wpadmin_filter', 10, 3);
function wpadmin_filter( $url, $path, $orig_scheme ) {
$old = array( "/(wp-admin)/");
$admin_dir = WP_ADMIN_DIR;
$new = array($admin_dir);
return preg_replace( $old, $new, $url, 1);
}
Add below line to .htaccess file
RewriteRule ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]
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.).
// Simple Query String Login page protection
function example_simple_query_string_protection_for_login_page() {
$QS = '?mySecretString=foobar';
$theRequest = 'http://' . $_SERVER['SERVER_NAME'] . '/' . 'wp-login.php' . '?'. $_SERVER['QUERY_STRING'];
// these are for testing
// echo $theRequest . '<br>';
// echo site_url('/wp-login.php').$QS.'<br>';
if ( site_url('/wp-login.php').$QS == $theRequest ) {
echo 'Query string matches';
} else {
header( 'Location: http://' . $_SERVER['SERVER_NAME'] . '/' );
}
}
add_action('login_head', 'example_simple_query_string_protection_for_login_page');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With