0

I am going to replace the front page of a Drupal 6 site with a new index.php. How can I rename the Drupal 6 index.php (say, to drupal.php) and keep the Drupal site functions working? For example, I'd like to have all the URL aliases work as before.

Is changing:

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

to:

RewriteRule ^(.*)$ drupal.php?q=$1 [L,QSA]

in .htaccess all what I need?

I need Drupal to co-exist with another site (which should be load by default) in the same http doc directory, and to keep existing Drupal functions (a few webforms).

2

1 Answer 1

2

Others have advised you not to do this. I too remain in that idea, but to answer your question:

Can Drupal even run without index.php? Can it be a different file name?

Technically it's possible for Drupal to run on any different directory index file name. But you need to configure your web server for that first. Unfortunately you will need to hack core as well, which is considered without-doubt a bad idea.

.htaccess changes

Assuming you are using Apache, and because it can automatically detect http://example.com?q=node and http://example.com/drupal.php?q=node if the DirectoryIndex drupal.php, you will only need to change the .htaccess file.

if your web server is not Apache and if you can't configure it to above URL patterns, you have to modify line 1518 in common.inc as well (Drupal 6.31). Things will get much complex in Drupal 7.x. You will have to make several hacks which you will find difficult to maintain patches for.

In your .htaccess, change these (using "drupal.php" as the new file name).

  • ErrorDocument 404 /index.php to ErrorDocument 404 /drupal.php

  • DirectoryIndex index.php to DirectoryIndex drupal.php

  • RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] to RewriteRule ^(.*)$ drupal.php?q=$1 [L,QSA]

You will probably need to modify your unit tests and shell scripts as well.

3
  • I am using Drupal 6 on Apache. Does it mean 1) renaming index.php and 2) modifying .htaccess are enough (no change to any Drupal core files is needed)?
    – ohho
    Commented May 16, 2014 at 4:40
  • 1
    .htaccess is part of core, right? Yes it should work if you did those 2. Consider putting this code in the apache conf files and disabling .htaccess parsing for the Drupal root. You will need to enable then back in the file upload folders or add relevant rules to the conf file and forget htaccess files altogether.
    – AKS
    Commented May 16, 2014 at 4:42
  • @AyeshK Your comment above is as valuable, or even more, than the answer itself. Consider merging it into your answer. +1 from me anyway, on both. Also note that simply substitution will not fulfil OPs all needs. In a minute I'll copy his additions from comments to the question.
    – Mołot
    Commented May 16, 2014 at 6:36

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