4

I'd like to configure my Drupal 6's site's front page to be "foo/index.htm", a hand-coded html file. But when I put that relative URL into Home › Administer › Site configuration › Default Front Page, it complains "The path 'foo/index.htm' is either invalid or you do not have access to it." It's a unix filesystem and everything is world-read, and the directories are world-execute. What could be the problem here?

2

The issue is the path in question here must be a valid Drupal path, not a Unix path/filename. I'd suggest investigating hook_menu() as a first step of learning about Drupal paths, callbacks and so forth.

1

The code that is causing that error is part of the form validation handler for the form you are submitting. (See system_site_information_settings_validate().)

// Validate front page path.
if (!drupal_valid_path($form_state['values']['site_frontpage'])) {
  form_set_error('site_frontpage', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_frontpage'])));
}

drupal_valid_path() considers the passed path valid if:

  • It is <front>
  • It is considered external, i.e. an absolute path starting with the protocol string
  • It is a path defined from a module

Notice that the form validation handler doesn't check the value for the front page path is a relative path, but drupal_is_front_page() contains the following code.

$is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'node'));

This means the path for the front page needs to be relative.

1

I would actually look at modifying the .htaccess file to serve your HTML file instead of Drupal's index.php when someone attempts to visit your homepage.

If you look at the .htaccess file provided by Drupal, it only serves index.php when a file or directory does not exist on the server (lines 109-113). You can put a new rule right before that and tell Apache that rule should be the last rule run (which will skip any remaining rules if the conditions are matched). I think the following should work (based on the answer Htaccess rule to redirect domain to index.html):

RewriteRule ^$ foo/index.html [L]

As long as that rule runs before the Drupal rule that routes all traffic through index.php, it should serve your homepage instead of the default Drupal homepage. This will work as long as your homepage has a URL like http://www.MYDOMAIN.com/ and the user doesn't type anything else (like index.php or index.html). You'll also need to make sure that all links to the homepage inside Drupal point to the correct URL (for example, the logo link, etc).

Also, because this is a modification to the .htaccess file, you'll need to make sure to copy the change over to the new .htaccess file when doing Drupal core updates.

0
  1. Use Front Page module, in the configuration page, 'Home links' tab, set to 'xxx.html'.
  2. Done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.