• GoDaddy Community
  • GoCentral | Website Builder
  • GoCentral | Website Builder

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    Go to solution

    default index.php in a subdirectory

    Hello,

     

    I have a website where I have the index.php page for the website in a subdirectory. How can I point people typing in "mydomain.com" to be directed to the file "main/index.php" instead of "index.php"?

     

    I saw in PLESK how to change the index page in the web root, but how to change it so it points to the "main/index.php" page as the default?

     

    Thank you for your help.

    2 REPLIES 2
    Pro Community Founder Artisan Pro Community Founder Artisan
    Pro Community Founder Artisan

    Re: default index.php in a subdirectory

    Hi @ralphjagodka,

     

    You can accomplish this by using an htaccess file rewrite -- 

     

    Here is a link with some excellent examples of how this file is used.  Also, keep in mind that some programming requires the htaccess rewrite apply to the new "relative root" for main/index.php.

     

    https://www.askapache.com/htaccess/modrewrite-tips-tricks/#htaccess_rewrite_examples

     

    Hope this helps,

    James

    Not Just Pretty Sites, Pretty Doggone Smart Sites
    Solution

    resoRe: default index.php in a subdirectory

    Hello James, Thank you for the great resource.

    Another resource I found was: https://my.bluehost.com/cgi/help/347

     

    This is what I have put together for it:

     

    # .htaccess main domain to subdirectory redirect 
    # Do not change this line. 
    RewriteEngine on 
    # Change example.com to be your main domain. 
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
    # Change 'subdirectory' to be the directory you will use for your main domain. 
    RewriteCond %{REQUEST_URI} !^/subdirectory/ 
    # Don't change the following two lines. 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    # Change 'subdirectory' to be the directory you will use for your main domain. 
    RewriteRule ^(.*)$ /subdirectory/$1 
    # Change example.com to be your main domain again. 
    # Change 'subdirectory' to be the directory you will use for your main domain 
    # followed by / then the main file for your site, index.php, index.html, etc.
     
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
    RewriteRule ^(/)?$ subdirectory/index.html [L]

    Visitors to the Web site will not be able to tell that my main domain is using a subdirectory, they will still see the Web site address as http://www.example.com/page.html.

     

    Thank you for the help!

     

    Ralph