最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - FORCE_SSL_ADMIN not working

programmeradmin1浏览0评论

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

Share Improve this question edited Dec 4, 2014 at 9:50 Pieter Goosen 55.4k23 gold badges115 silver badges210 bronze badges asked Dec 4, 2014 at 9:40 bsmoobsmoo 1511 gold badge1 silver badge5 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 4

Just 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

发布评论

评论列表(0)

  1. 暂无评论