SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Threaded View

  1. #1
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    City of Angels
    74 Post(s)
    6 Thread(s)

    Is it possible to have a single .htaccess file for both localhost and online

    Hi All,

    Unfortunately I have Googled and not been able to find a solution so...

    Two different .htaccess files required for http://localhost and
    Having to maintain two different .htaccess files with the same name.
    Try to prevent renaming and uploading incorrect .htaccess files

    I would prefer a single .htaccess file that detects HOST and performs relevant script

    I struggle with Apache's htaccess and have a hard job in trying to find the relevant
    information in the wealth of free advice

    With PHP this is a simple task:

    # PHP eqivalent to Apache .htaccess file
    PHP Code:

    #test host
    defined('LOCALHOST') ? NULL define('LOCALHOST'in_array($_SERVER['SERVER_NAME'], array('localhost''') ));

    # condition for specific host
    if( LOCALHOST )
    # Read somewhere that not availalble in Apache
    # if( ! LOCALHOST )
    #Common stuff
    ErrorDocument 404 /404.php 
    Last edited by John_Betong; Mar 14, 2012 at 22:17. Reason: formatting comments
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts