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
- PHP “or” Syntax
- Invalid column count in CSV input on line 1 Error
- How to check if a string starts with a specified string?
- How to run php files on my computer
- $wpdb->update or $wpdb->insert results in slashes being added in front of quotes
- Are there dictionaries in php?
- laravel updateOrCreate method
- How to listen messageSent event in laravel 5.5
- How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
- pdo – Call to a member function prepare() on a non-object
- Compare given date with today
- Replace spaces with a dash in a URL
- Are PDO prepared statements sufficient to prevent SQL injection?
- Message: Trying to access array offset on value of type null [duplicate]
- retrieve data from db and display it in table in php .. see this code whats wrong with it?
- Count how many files in directory PHP
- Simple PHP calculator
- Convert from MySQL datetime to another format with PHP
- php foreach with multidimensional array
- Mixed Content Page: requested an insecure stylesheet error
- header location not working in my php code
- PHP Error: Function name must be a string
- Uncaught Error: Call to undefined function mysql_escape_string()
- Warning: mysqli_query() expects at least 2 parameters, 1 given. What? [duplicate]
- PHP cURL custom headers
- Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 201:
- PHP “&” operator
- What is ?
- How to import csv file in PHP?
- What is the syntax for accessing PHP object properties?
- * failed to open vchiq instance
- Mysql where id is in array
- How to extract and access data from JSON with PHP?
- Warning “Do not Access Superglobal $_POST Array Directly” on Netbeans 7.4 for PHP
- Call a REST API in PHP
- Fatal error: Call to a member function query() on null
- PHP + JQuery – How to use these two together? Please see my example
- Data extraction from /Filter /FlateDecode PDF stream in PHP
- How to use data-saferedirecturl in a tag in PHP?
- PHP date yesterday [duplicate]
- Clear cache in Symfony: `cache:clear` or `rm -rf`?
- create php live clock
- Converting a UNIX Timestamp to Formatted Date String
- PHP Call to undefined function
- Formatting a number with leading zeros in PHP
- POST an array from an HTML form without javascript
- Switching MultiSite installation from HTTP to HTTPS
- cURL 28 error after switch from to brew php 7.2 on localhost
- Disable all https in WordPress
- Force HTTPS using .htaccess – stuck in redirect loop
- bloginfo() and get_template_directory_uri() with SSL?
- Globally force SSL on all pages
- WordPress redirect loop on nginx + apache reverse proxy
- WordPress multisite causing Error 101 (net::ERR_CONNECTION_RESET): Unknown error [duplicate]
- Is it possible to move wordpress out of webroot?
- Evaluations of two wordpress security plans against php code injection attack
- WordPress Dashboards: slowness and timeouts
- Too many redirects after added SSL redirect on port 80 virtual host
- Website access with http and https
- How to control SSL in WordPress for automatically changing http to https?
- Permalinks are not working in WordPress in digitalocean
- Why does WordPress uses HTTPS for JS, CSS on EC2
- 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
- My site thinks it’s secure when it is fact not
- 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?
- Admin-area broken through weird issues
- Serve HTTPS requests from subdomain
- Restricting access to a file for everyone except logged in users