Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rewrites for ssl so apache behaves properly (#1124)
* Add rewrites for ssl so apache behaves properly * Refactor testcommon.GetLocalHTTPResponse() to return resp for extra checking * Add TestHttpsRedirection()
- Loading branch information
Showing
11 changed files
with
148 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# DirectorySlash off | ||
# DirectoryIndex index.php | ||
# DirectorySlash off | ||
# DirectoryIndexRedirect on | ||
# Redirect to HTTPS before Apache mod_dir DirectorySlash redirect to HTTP | ||
RewriteCond %{HTTP:X-Forwarded-Proto} =https | ||
RewriteCond %{LA-U:REQUEST_FILENAME} -d | ||
RewriteRule ^/(.*[^/])$ https://%{HTTP_HOST}/$1/ [R=301,L,QSA] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
echo "Hi there, this is /index.php<br/>"; | ||
|
||
echo 'Here are links to <a href="/landed.php">landed.php</a> and <a href="subdir">subdir</a><br/>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
|
||
echo "You landed at ${_SERVER['REQUEST_URI']}<br/>"; | ||
echo "HTTPS is {$_SERVER['HTTPS']}<br/>"; | ||
|
||
echo 'You can go to <a href="redir_abs.php">redir_abs.php</a> or to <a href="redir_relative.php">redir_relative.php</a><br/>'; | ||
|
||
|
||
if (!empty($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") { | ||
echo "You can <a href='http://${_SERVER['HTTP_HOST']}/landed.php'>switch from https to http</a><br/>"; | ||
} else { | ||
echo "You can <a href='https://${_SERVER['HTTP_HOST']}/landed.php'>switch from http to https</a><br/>"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https://" : "http://"; | ||
$url = $scheme . $_SERVER['HTTP_HOST'] . "/landed.php"; | ||
header('Location: ' . $url, true, 302); // Use either 301 or 302 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
header('Location: ' . "/landed.php", true, 302); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is subdir/index.html; When you get here you should still have the scheme where you came from (shouldn't switch between http and https).<br/> | ||
<a href="/">Go back to the top.</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters