diff -urN -x files -x image -x conf.php -x gramma.tiker.net.php -x misc -x marksmarty -x inline.module -x textile -x smileys.module -x title.module -x goofy -x sunflower -x interlaced -x webfiles drupal-4.5.1/404.php drupal-4.5.1-clean404/404.php
--- drupal-4.5.1/404.php	1970-01-01 01:00:00.000000000 +0100
+++ drupal-4.5.1-clean404/404.php	2005-01-04 22:33:19.000000000 +0100
@@ -0,0 +1,5 @@
+<?php
+$_GET["q"] = $_SERVER['REQUEST_URI'];
+header("Status: 200 OK", TRUE, 200);
+include("index.php");
+?>
diff -urN -x files -x image -x conf.php -x gramma.tiker.net.php -x misc -x marksmarty -x inline.module -x textile -x smileys.module -x title.module -x goofy -x sunflower -x interlaced -x webfiles drupal-4.5.1/.htaccess drupal-4.5.1-clean404/.htaccess
--- drupal-4.5.1/.htaccess	2004-10-09 22:41:49.000000000 +0200
+++ drupal-4.5.1-clean404/.htaccess	2005-01-04 22:33:57.000000000 +0100
@@ -12,8 +12,8 @@
 Options -Indexes
 Options +FollowSymLinks
 
-# Customized server error messages:
-ErrorDocument 404 /index.php
+# Customized server error messages and/or GET-only clean URLs.
+ErrorDocument 404 /404.php
 
 # Set the default handler to index.php:
 DirectoryIndex index.php
diff -urN -x files -x image -x conf.php -x gramma.tiker.net.php -x misc -x marksmarty -x inline.module -x textile -x smileys.module -x title.module -x goofy -x sunflower -x interlaced -x webfiles drupal-4.5.1/includes/common.inc drupal-4.5.1-clean404/includes/common.inc
--- drupal-4.5.1/includes/common.inc	2004-11-29 18:59:50.000000000 +0100
+++ drupal-4.5.1-clean404/includes/common.inc	2005-01-04 22:33:19.000000000 +0100
@@ -164,7 +164,7 @@
  * Generates a 404 error if the request can not be handled.
  */
 function drupal_not_found() {
-  header('HTTP/1.0 404 Not Found');
+  header('Status: 404 Not found', TRUE, 404);
   watchdog('httpd', t('404 error: %page not found.', array('%page' => '<em>'. check_query($_GET['q']) .'</em>')));
 
   $path = drupal_get_normal_path(variable_get('site_404', ''));
@@ -183,7 +183,7 @@
  * Generates a 403 error if the request is not allowed.
  */
 function drupal_access_denied() {
-  header('HTTP/1.0 403 Forbidden');
+  header('Status: 403 Forbidden', TRUE, 403);
 
   $path = drupal_get_normal_path(variable_get('site_403', ''));
   $status = MENU_NOT_FOUND;
@@ -1005,6 +1005,25 @@
  * must be explicitly generated by modules.
  */
 
+ /**
+ * Reverse of parse_str().  Converts array into
+ * string with query format. 
+ *
+ * By dante@lorenso.com, from PHP documentation. Might need to be moved away 
+ * from here.
+ */
+
+function query_str($params) {
+  if (count($params) == 0) return NULL;
+
+  $str = '';
+  foreach ($params as $key => $value) {
+    $str .= (strlen($str) < 1) ? '' : '&';
+    $str .= $key . '=' . rawurlencode($value);
+  }
+  return ($str);
+}
+
 /**
  * Generate a form from a set of form elements.
  *
@@ -1020,9 +1039,43 @@
  *   An HTML string with the contents of $form wrapped in a form tag.
  */
 function form($form, $method = 'post', $action = NULL, $attributes = NULL) {
+  global $base_url;
   if (!$action) {
     $action = request_uri();
   }
+
+  $parsed_base_url = parse_url($base_url);
+  $base_path = $parsed_base_url['path'];
+  $parsed_action = parse_url($action);
+  $action_query = isset($parsed_action['query']) ? $parsed_action['query'] : NULL;
+  $action_path = isset($parsed_action['path']) ? $parsed_action['path'] : NULL;
+  $action_fragment = isset($parsed_action['fragment']) ? $parsed_action['fragment'] : NULL;
+  
+  if (substr($action_path, 0, strlen($base_path)) == $base_path) {
+    parse_str($action_query, $query_components);
+
+    $remainder = substr($action_path,strlen($base_path));
+
+    // Chop a leading slash, if any.
+    if (substr($remainder, 0, 1) == "/") {
+      $remainder = substr($remainder, 1);
+    }
+
+    if (isset($query_components['q']))
+    {
+      // Query of style index.php?q=...
+      $q_string = $query_components['q'];
+      unset($query_components['q']);
+      
+      $action = url($q_string, query_str($query_components), $action_fragment, FALSE, TRUE);
+    }
+    else
+    {
+      // Query of "clean" style.
+      $action = url($remainder, $action_query, $action_fragment, FALSE, TRUE);
+    }
+  }
+
   return '<form action="'. $action .'" method="'. $method .'"'. drupal_attributes($attributes) .">\n". $form ."\n</form>\n";
 }
 
@@ -1484,33 +1537,47 @@
  * @param $absolute
  *   Whether to force the output to be an absolute link (beginning with http:).
  *   Useful for links that will be displayed outside the site, such as in an RSS feed.
+ * @param $isform
+ *   Whether the URL is meant for form submission. This may suppress the generation
+ *   of clean URLs in "Clean only for GET" mode.
  * @return
  *   an HTML string containing a link to the given path.
  *
  * When creating links in modules, consider whether l() could be a better
  * alternative than url().
  */
-function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
+function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE, $isform = FALSE) {
   global $base_url;
 
   static $script;
 
-  if (empty($script)) {
-    // On some web servers, such as IIS, we can't omit "index.php".  So, we
-    // generate "index.php?q=foo" instead of "?q=foo" on anything that is not
-    // Apache.
-    $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : '';
-  }
-
   $path = drupal_get_path_alias($path);
 
   if (isset($fragment)) {
     $fragment = '#'. $fragment;
   }
 
+  $clean_url_var = variable_get('clean_url', '0');
+  $use_clean_url = $clean_url_var != '0';
+  
+  if ($isform && $use_clean_url == "2") {
+    $use_clean_url = FALSE;
+
+    // We need to force absolute since we don't want /admin/index.php?q=...
+    // put together by the browser if all we specify is index.php?q=... .
+    $absolute = TRUE;
+  }
+
   $base = ($absolute ? $base_url . '/' : '');
 
-  if (variable_get('clean_url', '0') == '0') {
+  if (empty($script)) {
+    // On some web servers, such as IIS, we can't omit "index.php".  So, we
+    // generate "index.php?q=foo" instead of "?q=foo" on anything that is not
+    // Apache.
+    $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : '';
+  }
+
+  if (!$use_clean_url) {
     if (isset($path)) {
       if (isset($query)) {
         return $base . $script .'?q='. $path .'&amp;'. $query . $fragment;
diff -urN -x files -x image -x conf.php -x gramma.tiker.net.php -x misc -x marksmarty -x inline.module -x textile -x smileys.module -x title.module -x goofy -x sunflower -x interlaced -x webfiles drupal-4.5.1/modules/system.module drupal-4.5.1-clean404/modules/system.module
--- drupal-4.5.1/modules/system.module	2004-11-30 19:40:48.000000000 +0100
+++ drupal-4.5.1-clean404/modules/system.module	2005-01-04 22:33:19.000000000 +0100
@@ -185,7 +185,7 @@
   $group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page.  Useful for adding a copyright notice to your pages.'));
   $group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.'));
   $group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL.  If you are not using clean URLs, specify the part after "?q=".  If unsure, specify "node".'));
-  $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable clean URLs.  If enabled, you\'ll need <code>ModRewrite</code> support.  See also the <code>.htaccess</code> file in Drupal\'s top-level directory.'));
+  $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled'), t('Enabled for GET requests only')), t('Enable or disable clean URLs.  If enabled, you will need <code>ModRewrite</code> support.  See also the <code>.htaccess</code> file in Drupal\'s top-level directory. The GET-only option uses clean URLs only for GET requests. It is supposed to work with ErrorDocument redirection, which you need to point at the supplied 404.php. (POST form data does not survive the ErrorDocument redirection.)'));
 
   $output = form_group(t('General settings'), $group);
 
