The way I’ve done it before is basically like what you wrote, but doesn’t have any hardcoded values:if($_SERVER[“HTTPS”] != “on”) { header(“Location: https://” . $_SERVER[“HTTP_HOST”] . $_SERVER[“REQUEST_URI”]); exit(); }
Related Posts:
- How to force Laravel Project to use HTTPS for all routes?
- Not logged in when using http
- http://localhost:80 is not working on running Apache server through UniServer ZeroXIII
- How do I resolve a HTTP 414 “Request URI too long” error?
- Getting an error when I visit http://localhost
- Redirect vs RedirectMatch
- Make a HTTPS request through PHP and get response
- What is the difference between the ‘www’ folder and ‘htdocs’ folder?
- What is Options +FollowSymLinks?
- cURL error 60: SSL certificate: unable to get local issuer certificate
- SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- How do you redirect HTTPS to HTTP?
- Only variable references should be returned by reference – Codeigniter
- Connection reset by peer: mod_fcgid: error reading data from FastCGI server
- file_get_contents( ) not working
- Error:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
- XAMPP, using port:81, cannot run localhost:81/mywebsite
- “End of script output before headers” in Apache + PHP
- How to find out if you’re using HTTPS without $_SERVER[‘HTTPS’]
- Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
- Using PHP 7 with WAMP
- How to remove index.php from WordPress site URL
- Redirecting from HTTP to HTTPS with PHP
- file_get_contents() how to fix error “Failed to open stream”, “No such file”
- Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
- How can I fix the mixed content problems of the kk star ratings plugin?
- https and wordpress breaks posts
- Front-end pages messed up due to HTTPS
- Replace ' and similar html codes with their correspondent character?
- Google Calendar API event update always return 404 “not found” error
- How to prevent the “Confirm Form Resubmission” dialog?
- Generate HTTPS Urls in multisite
- Permalinks are not working in WordPress in digitalocean
- WordPress CSS/Theme gone after SSL got activated
- My site doesn’t redirect from HTTP to HTTPS
- fix 302 redirection error on https
- Gravatar image url is wrong?
- How to get Caching Plug-ins to work on localhost with HTTPS?
- https to https problem – 404 and can’t login
- ERR_TOO_MANY_REDIRECTS on wordpress page [closed]
- Only execute function if SSL is set up properly
- URLs not being output with https
- Apache HTTP Server stops working for only a certain local website
- HTTPS to HTTP rewrite rules not working as expected
- How to enable http (not just https) in wordpress?
- Check against server time to display SQL entries – Radio Station DJ Rotator Plugin
- How can I rewrite old attachment URLs?
- Plugin error after installation
- Problem with data collection in tables
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- Website Migration (with https) to a new domain(http)
- How to move my local wordpress to https?
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- Why does WordPress uses HTTPS for JS, CSS on EC2
- Specific Page/Post Need to Stay Non SSL
- 301 Redirect Loop www to non-www – Nginx + Apache2
- How to edit content in WordPress and the Polylang – plugin? – with demosite
- Upgrade to PHP7.3 and Changing Apache from Prefork to Event Breaks WordPress
- After using ssl certificate, wordpress doesn’t work
- Mixed Content: The page at ” was loaded over HTTPS, but requested an insecure font ”
- Since moving HTTPS using cloudflare, the admin and login pages no longer work
- Implications of not completing all tasks when switching to HTTPS
- Windows Setup: Error establishing a database connection
- How to convert multisite subdomain from http to https
- WordPress Multisite keeps redirecting to HTTPS
- Huge time to first byte on live site
- I get “too many redirects” problem when migrating localhost site
- Cannot access wp-admin after installing SSL – user capabilities not being set
- Why my multisite is this slow? (stats inside)
- WAMP SERVER Command Prompt SET PATH=%PATH%
- Change home_url in searchform.php to go to HTTPS instead of HTTP
- How to force the admin-ajax.php file to load over HTTPS?
- SSL Certificate
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- 404 Page not found error after adding ‘s’ in ‘http’ in Settings
- Full search and replace isn’t enough to make all pictures to be loaded with https
- How to send user data from one website to another
- How to detect if an other front-end post/page is in HTTPS/SSL from admin to display a notice?
- How come all my http URLs are turned to https?
- Forcing SSL (Bad Theme coding)
- Moving site from HTTP to HTTPS
- 403 Forbidden Localhost Wamp Apache Php
- How to switch static files back to using HTTP instead of HTTPS?
- Strange special character/Latin characters
- Create a new hyperlink to wordpress blog
- My site thinks it’s secure when it is fact not
- Rewrite /keyword1+keyword2.html to search page | .htaccess
- PHP Warning:fread(): SSL: Connection reset by peer in /var/www/html/wp-includes/class-wp-http-streams.php line 269
- Mixed content and expired session issues with SSL and wp-admin
- Core update of 4.2.3 changes all link to https [duplicate]
- How do I secure a subdomain using UCC SSL?
- W3 Total Cache Can’t Really Detect Things
- My WordPress site SSL is in red crossed color and can’t load at first time?
- Admin-area broken through weird issues
- Access wordpress pages using a self signed shared ssl
- Any idea on how to fix this error when forcing SSL on a certain page?
- Blog only showing code
- Serve HTTPS requests from subdomain