<p>I've got just one page that I want to force to be accessed as an HTTPS page (PHP on Apache). How do I do this without making the whole directory require HTTPS? Or, if you submit a form to an HTTPS page from an HTTP page, does it send it by HTTPS instead of HTTP?</p>
<p>Here is my example:</p>
<pre><code>http://www.example.com/some-page.php
</code></pre>
<p>I want it to only be accessed through:</p>
<pre><code>https://www.example.com/some-page.php
</code></pre>
<p>Sure, I can put all of the links to this page pointed at the HTTPS version, but that doesn't stop some fool from accessing it through HTTP on purpose...</p>
<p>One thing I thought was putting a redirect in the header of the PHP file to check to be sure that they are accessing the HTTPS version:</p>
<pre><code>if($_SERVER[&quot;SCRIPT_URI&quot;] == &quot;http://www.example.com/some-page.php&quot;){
  header('Location: https://www.example.com/some-page.php');
}
</code></pre>
<p>But that can't be the right way, can it?</p>

You could do it with a  directive and mod_rewrite on Apache:
```
```
<Location /buyCrap.php>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Location>
```
```
You could make the Location smarter over time using
regular expressions
if you want.