/maindomain/ is a folder that contains all the content for maindomain.com. This folders sits inside /public_html/ When someone types in "www.maindomain.com/maindomain/", is there a way to have it re-direct to www.maindomain.com?
Just save the following code as index.php in the "www.maindomain.com/maindomain/" folder <?php redirect_to_url('../index.php'); function redirect_to_url( $relative_url = 'index.php' ) { if ( ( dirname($_SERVER[ 'PHP_SELF' ]) == '\\' || dirname($_SERVER[ 'PHP_SELF' ]) == '/' ) ) { // Hosted at root. header('Location: http://'.$_SERVER[ 'HTTP_HOST' ].'/'.$relative_url); } else { // Hosted in sub-directory. header('Location: http://'.$_SERVER[ 'HTTP_HOST' ].dirname($_SERVER[ 'PHP_SELF' ]).'/'.$relative_url); } exit; } ?> Code (markup):
Guttu, thank you, the code looks really good. I won't get a chance to try it out for a while as I ended up just throwing all of the contents in the /maindomain/ folder and putting them in the root under /public_html/ and of course editing the .htaccess file which works great with the exception that my files are now scattered. I'll give this a shot down the road when I get a chance. Thanks so much once again for the code.