Disabling HTTPS and Redirecting to HTTP in WordPress
When a project is in a testing phase, pointing a live domain to a new server without purchasing an SSL certificate yet can create friction. You might want to verify functionality on port 80 using an IP address, but the application layer often insists on using TLS. This mismatch typically manifests as mixed content warnings: your HTML loads over HTTP, but the browser forces CSS, JavaScript, and images to load via HTTPS because they are hardcoded or served by a plugin expecting a secure connection.
The core issue is that WordPress, by default, treats all asset requests as secure if FORCE_SSL_ADMIN is set or if the site URL is defined with an https:// prefix. Even if you configure .htaccess to redirect incoming HTTPS traffic to HTTP, the server might still serve the assets via HTTPS before the redirect logic executes, or the browser caches the secure versions of these files.
Understanding the Root Cause
The problem isn't just that you want to use HTTP; it's that WordPress and your theme are generating URLs with https:// in the source code of the output. When you access http://<ip-address>, the server might automatically upgrade the connection to HTTPS (a behavior common on Apache or Nginx when certificates are present, even if not strictly enforced by the admin panel).
If your SSL certificate is installed but you haven't updated your WordPress settings to reflect that the site is not secure, WordPress will generate links like https://example.com/wp-content/themes/.... When the browser receives these links over an HTTP connection, it flags them as "Mixed Content" and blocks them or attempts to upgrade the request, depending on the browser security level.
Fixing the .htaccess Redirect Logic
A common first step is modifying the .htaccess file to force a redirect from https:// to http://. The snippet provided in many forums often looks like this:
RewriteEngine On
RewriteCond %{HTTP} !=on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
While well-intentioned, this logic has a flaw. The condition RewriteCond %{HTTP} !=on checks if the protocol is not HTTP. However, if your server is configured to automatically upgrade the connection (which happens if a certificate is detected), the request arrives at your .htaccess rules as HTTPS anyway. You need to explicitly force the protocol change regardless of the incoming scheme.
A more robust approach ensures that any request coming in over port 443 is redirected to port 80:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This condition checks the HTTPS environment variable, which is set to "on" only if the request was originally made over SSL. This prevents infinite redirects and ensures that even if a browser attempts to load assets via HTTPS, it gets sent back to HTTP immediately.
Clearing Caches and Resetting WordPress Settings
Once the server-level redirect is in place, you must ensure WordPress itself isn't fighting you. Check your database table wp_options for the siteurl and home entries. If these are set to https://, WordPress will continue to generate secure URLs even if the server redirects them. Update both fields to http://<ip-address>.
Additionally, check your wp-config.php file. The line define('FORCE_SSL_ADMIN', true); forces the admin dashboard to use HTTPS only. While this is good for security in production, during testing on HTTP, you should ensure no other constants are forcing SSL globally. Remove any lines defining FORCE_SSL, HTTPS, or similar if they exist, unless you have a specific reason to keep them.
Finally, clear your browser cache and the server-side cache (if using Redis or Memcached). Browsers often cache 304 Not Modified responses for static assets, meaning they might try to fetch the CSS file over HTTPS again because they believe it hasn't changed. Accessing the site as an incognito user can help verify that the redirection is working and assets are loading correctly over HTTP.
Why This Matters for Development
Disabling HTTPS in this manner allows you to debug themes and plugins without the overhead of certificate management or complex HSTS configurations. However, remember that this setup is strictly for local or staging environments where security is not the primary concern. Once SSL certificates are purchased and installed, you should reverse these changes immediately. Reverting to https:// in your database settings and removing the redirect rules will ensure a secure production environment.
