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
- SSL Error: unable to get local issuer certificate
- How to redirect all HTTP requests to HTTPS
- https connection using CURL from command line
- Curl command for https ( SSL )
- nodejs – error self signed certificate in certificate chain
- Simple Java HTTPS server
- HTTPS connection Python
- Java: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- SSL_ERROR_BAD_CERT_DOMAIN
- Mixed Content Page: requested an insecure stylesheet error
- How do you redirect HTTPS to HTTP?
- Could not establish secure channel for SSL/TLS with authority ‘*’
- Python requests SSL error – certificate verify failed
- Https to http redirect using htaccess
- How can I force users to access my page over HTTPS instead of HTTP?
- How to force Laravel Project to use HTTPS for all routes?
- How can I fix the “No certificates found – The app Chrome has requested a certificate” Android / Google Chrome issue
- Issues with installing python libraries on Windows : CondaHTTPError: HTTP 000 CONNECTION FAILED for url
- Best collection of code for your .htaccess file [closed]
- SSL Breaks WordPress CSS
- Site Redirecting to wp-signup.php
- Moving a WP Multisite to a subdirectory
- Default .htaccess file for WordPress?
- Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
- Switching MultiSite installation from HTTP to HTTPS
- Why is WordPress redirecting from http to https on a local environment?
- Improve wordpress security by hiding non public resources
- WordPress site hacked. Has .htaccess been hacked?
- Does this .htaccess security setting really work?
- Use a different domain for SSL
- Is there a way to force ssl on certain pages
- htaccess problem after saving Settings
- multisite 404 error for subdirectory
- SSL breaks customizer: page isn’t returned from ajax
- Move WordPress to subdirectory, keep ALL URLs
- Disable all https in WordPress
- File and directory permissions
- htaccess disable WordPress rewrite rules for folder and its contents
- WP-Admin not working properly at WordPress multisite with subdirectories
- How to use WordPress multisite with mixed HTTP and HTTPS sites?
- Local version of a WordPress site – SSL/HTTPS enforced?
- bloginfo() and get_template_directory_uri() with SSL?
- Permalink Issues by Installing WordPress in Subdirectory / Subfolder
- Htaccess for Wordpess set on single subdomain
- After updating site to use SSL all images in posts point to http://
- adding rewrite rules in .htaccess
- .htaccess and 500 error, extra character added
- WordPress is Inserting images into Post as HTTP and not HTTPS
- Name-based virtual host configuration in Apache seems to cause a “500 Internal Server Error”
- Place static HTML files in path below WordPress page
- WordPress multisite subdirectory redirect infinite loop issue
- Static raw HTML page
- WordPress + Magento .htaccess ReWriteRule Issue (www vs. non-www)
- Plugin to edit htaccess file
- Adding https to wordpress website
- Upgrade to SSL Breaks Admin Dashboard
- htaccess rewrite for author query string when WP is in subfolder