I just registered a new domain name and am building my first Drupal site. I don't want anyone to casually or accidentally drop in and see it in the middle of development.

My solution was to create a basic index.html page which just says "Coming soon". I then edited the .htaccess file in the root of the website and changed this line:

DirectoryIndex index.php

to

DirectoryIndex index.html

so that the index.html file opens whenever anyone types "www.mysite.com". I can still access Drupal by typing "www.mysite.com/index.php" and continue work on the site.

The only irritation is that when I navigate back to the main page, I get my "coming soon" message and have to type the address for the .php page again since Drupal defaults to opening the domain without a file extension (although I made a button for the main page on my navigation bar so it takes no time at all)

Is there a better way to do this without getting too involved? I understand that this won't keep anyone from accessing a specific page on the site directly, but since no site has ever been there before, no one would have any pages saved as links.

Tired of staric sites and looking forward to the learning curve.....

Comments

dshah’s picture

Use the site offline feature. In admin you can set the site offline with custom message to users.

You can still login and perform admin etc functions while users get nice message.

Use http://www.example.com/?q=user to login

heine’s picture

Unfortunately that functionality is not present in 4.6...

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

kae’s picture

sounds like it's in 4.7. would be nice if it can be backported but I guess it's using the 4.7 form api.

shane’s picture

I simply have a DNS hostname of test.domain.com setup. Then I use a Virtual Host to send test.domain.com to a /web/whatever/test/ directory which is my testing Drupal install.

My public Drupal install is at /web/whatever/public (which is the www.domain.com main site). I keep two databases. The whatever-public database, and then a duplicate copy of it called whatever-test.

Then, when I'm done developing, I simply copy the files from the /web/whatever/test directory over the top of /web/whatever/public. Then copy the database over the top of the existing DB as well.

It's simple and manual - but it works well for me.

ankur’s picture

Ankur Rishi
(CivicSpace)

At the top of you index.php, include this snippet right after the opening <?php tag:

if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != 'Login' || $_SERVER['PHP_AUTH_PW'] != 'Password') {
   header('WWW-Authenticate: Basic realm="Testing"');
   header('HTTP/1.0 401 Unauthorized');
   echo 'Under construction';
   exit;
}

But remember to replace 'Login' and 'Password' with your own login/pass.


Jaza’s picture

You can set up basic authentication in your site's .htaccess file (you'll also need to create a .htpasswd file).

If you have a GUI tool such as cPanel, you can do this with a few clicks. To do it manually, see the Apache docs at http://httpd.apache.org/docs/1.3/howto/auth.html#basic.

This is how I protect my development sites from the outside world (while still allowing clients to see my work-in-progress). The only problem is that you can't run the cron scripts (such as cron-lynx.sh), because they can't get through the authentication to fire the cron run. There's probably a way around this (I guess you can somehow pass the login details to wget), but I don't know what it is. And regular cronning is not an issue for me with devel sites anyway: if I need the cron to run, I just fire it manually.

Jeremy Epstein - GreenAsh

Jeremy Epstein - GreenAsh

PakWaan’s picture

Thanks to all for your replies - I'm off to give them a shot.