Why is my custom module giving a "page not found" message when using https? I have a custom module that is a form. The first section in the hook_form() function is

if (!$_SERVER['HTTPS'] == 'on') {
    drupal_goto('https://mysite/mymodule');
}


If I comment out this section, the form works as expected. If the https redirect is left as is, I get a page not found error. This occurs only for unauthenticated users. If I am logged in, the form displays correctly.

I am on Drupal 6

EDIT: I turned off caching on my Drupal site and the form works again. The caching must have broken my form. I will see if I can find a way to not allow the form to be cached by Drupal.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


or take a look at this article