How to auto redirect IP address to a login PHP script?

1k Views Asked by At

I am using WAMP server, and I am a novice. Currently, I have many scripts under /www/mySite. I have set /www/mySite as my default location for the wamp server.

However, when you set the browser address to http://myIPAddress, it automatically shows a list of files under /www/mySite.

I don't want this. When the user points to http://myIPAddress, I want it to point directly to http://myIPAddress/main_login.php. How do I achieve this?

3

There are 3 best solutions below

0
On BEST ANSWER
  1. The simplest way is to rename your main_login.php to index.php
  2. You can also do it using your server configuration or .htaccess
  3. You may include another index.php and use its header like this

    <?php
    $redirection_url='main_login.php';
    header('Location: '. $redirection_url);
    ?>
    
2
On

Change the name of main_login.php to index.php (index.* is something apache reads as default page) or learn about .htaccess and redirect "/" (which is root of your webserver) to main_login.php

0
On

Basically there are two ways:

  • Changing the Apache configuration file an telling Apache to look up all the main_login.php file (by default it gets all the index files)
  • Changing the name of your file from main_login.php to index.php

Changing Apache configuration file

To change the Apache configuration file you must

  • Go to the httpd.conf file

  • Look for the DirectoryIndex row line

  • Edit it as you wish

  • Restart Apache

Renaaming your file

It's the simplest and best way.