I would recommend to define this constant in your wp-config.php
to force HTTPS on admin:
define('FORCE_SSL_ADMIN', true);
Also, there is a function called is_admin()
which could be helpful in your case.
if ( is_admin() ) {
$_SERVER['HTTPS'] = 'on';
}
However, if you have a rule in your web server forcing all wp-admin
and wp-login.php
requests to run over SSL, you will need to add an exception for admin-ajax.php
file. Not sure how to implement this in Apache, but for NGINX the easiest way would be something like:
if ($request_uri !~* "^/wp-admin/admin-ajax\.php") { rewrite "^/wp-(admin|login)" https://$host$request_uri permanent; }
Hope this helps!
Related Posts:
- Globally force SSL on all pages
- How disable SSL redirect for specific URL?
- How to modify the .htaccess to force ssl on login and admin pages
- Transfer to HTTPS – mixed content on main page only [closed]
- Https Redirect infinite loop in Mobile browsers
- 403 error on admin login page
- Adding a SSL Certificate
- HTTP sitewide, except for: wp-admin, and 2 custom directories
- Steps for WordPress over SSL
- Disable SSL / HTTPS for wordpress
- Which one does WordPress prioritize when it comes to php.ini, wp-config and .htaccess?
- Stop WordPress and Plugins from Overwriting .htaccess
- htaccess rewrite conflict with wordpress rules and ssl
- htaccess https redirect from www to non-www
- Force HTTPS using .htaccess – stuck in redirect loop
- How to redirect url requests to https? [closed]
- Locked out of WordPress Site Admin after enabling Force SSL on WordPress Https (SSL)
- Setup Permanent 301 Redirects after moving to Https [closed]
- https multiple redirects
- How to properly force https and www on multisite with Apache HTAccess
- Enable Full SSL for WordPress
- Redirect http to https does not work on subdir where another instance of WordPress installed
- I can’t access the admin panel links as I click it shows 403 error
- WP install in sub-dir white screen
- What is the right way to redirect all traffic to HTTPS?
- Htaccess file isn’t redirecting http sub-pages to https––they display 404 error instead, tried many solutions and none work
- WordPress – Promoting A Dev Build In A Subdirectory To Production / Root Directory
- How can I fix the redirect chain after implementing ssl on wordpress?
- How to block access to files without modifying .htaccess or ngnix config? [closed]
- Weird behavior of Dashboard, must be core files
- Forcing HTTPS with WordPress on AWS
- Locked out of admin and some pictures don’t show after failed SSL installation
- Conflict with Force SSL and Rewrite Rules
- ReDirect subfolder link to another sub-folder and force SSL
- Force non-ssl on WordPress RSS feeds in htaccess, using cloudflare
- fix 302 redirection error on https
- Redirect https://www.subdomain.domain.com is not redirecting to subdomain.website.com [closed]
- HTTPS to HTTP rewrite rules not working as expected
- WordPress constantly running out of memory
- Clone WordPress for testing on localhost (with Fiddler)
- Should I prevent access to .htaccess and wp-config.php files?
- .htaccess and virtual host configuration for WP in its own directory
- The connection to “domain” is not secure
- Mixed Content Page: requested an insecure stylesheet error
- SSL breaks customizer: page isn’t returned from ajax
- Local version of a WordPress site – SSL/HTTPS enforced?
- Static raw HTML page
- .htaccess file redirecting to parent directory
- 302 redirect instead of 301 after switch to HTTPS
- Redirect from https to http or from http to https? [closed]
- Correct htaccess to display page while also passing in GET parameters
- How have I misconfigured basic auth for my wordpress site?
- WordPress trims off the forward slash when import
- WordPress best solution shared theme for consumers and businesses (two url’s one instaltion)
- How to set up htaccess to redirect a particular post type or subdirectory to HTTPS?
- How to disable the default WordPress redirect to non-www URLs?
- WordPress 404 on Subdomain
- Can’t Access Subdirectory
- WordPress Dashboards: slowness and timeouts
- HTTP Error 406 always on site?
- Point all URLs to homepage but maintain URL
- htaccess working on local server but not on live server
- External content won’t load in iframe in Safari
- How to write .htaccess so that https is on for subpages only but not the home page
- 404 redirect wp-login and wp-admin after changing login url [closed]
- Too many redirects after added SSL redirect on port 80 virtual host
- Website access with http and https
- mod_rewrite doesn’t work as I want even with JSON API Plugin disabled
- WordPress .htaccess file gives issues with subdirectory
- W3 Total Cache CSS & JS files GZip issues [closed]
- WP Super Cache unable to locate cache file for only the homepage
- Cannot login to WordPress site after changing .htaccess for security purposes
- WordPress permalink, stop redirection
- add_rewrite_rule to remove /category/ from permalink
- Non WordPress Folder in a WordPress Site
- Htaccess rewrite based on query string, not working [closed]
- Redirect all subdomains to root domain
- Change root directory
- How to execute WordPress as though it is in the root folder while it is installed in a subdirectory?
- Htaccess maintenance page rules that actually work with WordPress?
- How to allow only vpn access to dashboard on Bitnami WordPress by IP address restricting
- Why does WordPress uses HTTPS for JS, CSS on EC2
- Blocking wp-login in HTACCESS has also blocked password protected pages
- Non-wordpress subdomain on Multisite Installation
- Unable leverage Browser Caching on AWS Bitnami stack (Apache) through W3TC and Cloudfront CDN
- Rewrite rules and maintain URL
- Subfolder renaming
- Resource 404 error on multisite subdirectory install
- My site thinks it’s secure when it is fact not
- Targeting .htaccess file with file_put_contents
- Redirect Loop in Regex Moving to HTTPS
- .htaccess file changes disappear
- WordPress login bug. Need an emergency solution
- How do I secure a subdomain using UCC SSL?
- My WordPress site SSL is in red crossed color and can’t load at first time?
- 403 forbidden due to .htaccess?
- Serve HTTPS requests from subdomain
- Where is the htaccess in wordpress.com hosting?
- Debug errors for “Destination directory for file streaming does not exist or is not writable”
- .htaccess seems to be required but I can not find it