Any ideas why define('FORCE_SSL_ADMIN', true);
wouldn't work?
I'm not getting any errors at all, but a http
request to example/wp-admin
isn't redirecting to https
Any ideas why define('FORCE_SSL_ADMIN', true);
wouldn't work?
I'm not getting any errors at all, but a http
request to example/wp-admin
isn't redirecting to https
3 Answers
Reset to default 4Just figured it out... It was the positioning of the define statement.
I added the below above the /* That's all, stop editing! Happy blogging. */
line
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
Thanks!
This can also happen if WordPress is hosted behind a reverse proxy that provides SSL.
Paste the following in your theme's functions.php:
define('FORCE_SSL_ADMIN', true);
// a comma-separated list e.g. http,https
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
I would even go as far as setting up .htaccess to rewrite the request to https for a specific folder, aka /wp-admin/ For example
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} wp-admin
RewriteRule ^(.*)$ https://www.yourdomain/wp-admin/$1 [R,L]
Also it looks like FORCE_SSL_LOGIN
was depreciated since 4.0, so in your answer you would only need FORCE_SSL_ADMIN
which should take care of LOGIN and ADMIN areas.
More on Administration Over SSL