+ Reply to Thread
Results 1 to 9 of 9

Thread: Redirect Root Directory to Subdirectory w/ Joomla

  1. #1
    caiol611 is offline x10Hosting Member caiol611 is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    7

    Redirect Root Directory to Subdirectory w/ Joomla

    I am a person who likes to keep everything organized under the /public_html/ folder. If you like to keep all the Joomla! files under a "joomla" folder or named whatever, you can do so and have your website redirect to the "joomla" directory without typing yoursiteurl.com/joomla. I use Joomla 1.5 so I know it works with 1.5.

    Create a .htaccess file under your /public_html/ folder. If you already have one there, great. If not create a text file in Microsoft Notepad and name it simply ".htaccess" with no file extension. Paste the following in the file:

    Code:
    # Turn on rewrites.
    RewriteEngine on
    
    # Only apply to URLs on this domain
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    
    # Only apply to URLs that aren't already under folder.
    RewriteCond %{REQUEST_URI} !^/folder/
    
    # Don't apply to URLs that go to existing files or folders.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all those to insert /folder.
    RewriteRule ^(.*)$ /folder/$1
    
    # Also redirect the root folder.
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    RewriteRule ^(/)?$ folder/index.php [L]
    Rename all the "domain.com" in the code to your site url (yourdomain.whatever). You will need to rename the "folder" to "joomla" or whichever subdirectory your Joomla files are housed in. Joomla! uses an index.php file but if you decide to apply this to your own site that uses an html index page, simply rename the "index.php" to "index.html" or whatever.

    Then go to the folder where your Joomla! files are located and find "configuration.php" under your Joomla root. Open the file in your favorite editor and find the line (if you can't find it just create one):

    Code:
    $mosConfig_live_site = 'http://mydomain.whatever/joomla';
    and replace it with:

    Code:
    $mosConfig_live_site = 'http://mydomain.whatever';
    That's it! Go to your website root and it should be redirected to your Joomla! subdirectory.
    Last edited by caiol611; 08-29-2008 at 02:59 PM.

  2. #2
    javajenius's Avatar
    javajenius is offline x10 Lieutenant javajenius is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    258

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    Ban the member above me.

  3. #3
    Sohail's Avatar
    Sohail is offline x10 Spammer Sohail is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    London, UK
    Posts
    3,052

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    It's been done. Nice tutorial by the way, I would have simply take all the files from inside the Joomla folder and paste it where it needs to be ;). But your idea is good too. I keep mine in the Joomla folder in public html but I have a sub-domain redirecting to it to keep everything organized, I hate having files I don't need all over the place ;).
    Last edited by Sohail; 09-08-2008 at 12:04 AM.

  4. #4
    JKnife is offline x10Hosting Member JKnife is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    49

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    much easier way and also one that can be reversed fairly quickly is to use a php file

    make a index.php file and put this small 1 line in it and change <url>/<your folder> to well.. your url and the folder you want it to redirect to.
    Code:
    <php header( "Location: <your url>/<your folder>" ); ?>
    granted this will add the /<folder> to the end of the url but you won't have to change any config files and well I like simplicity
    Last edited by JKnife; 09-08-2008 at 02:27 AM.
    My site - Deals with current events in politics and freedom vs. security. Also has a tech section for awareness ;)

  5. #5
    Sohail's Avatar
    Sohail is offline x10 Spammer Sohail is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    London, UK
    Posts
    3,052

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    Thanks, i think the PHP way is better, it's simple and easy to change...

  6. #6
    CypressBlade is offline x10Hosting Member CypressBlade is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    1

    Thumbs up Re: Redirect Root Directory to Subdirectory w/ Joomla

    Hi I would like to thank you for the info.
    Was searching for this for ages. I like to have things neat myself so this is very useful.

    Thanks a bunch!

  7. #7
    randy a. is offline x10Hosting Member randy a. is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    4

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    nice one bro!!!

  8. #8
    diego.miquel is offline x10Hosting Member diego.miquel is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    11

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    Gracias, muy bueno.

  9. #9
    zisiadism67 is offline x10Hosting Member zisiadism67 is an unknown quantity at this point
    Join Date
    Jan 2011
    Posts
    6

    Re: Redirect Root Directory to Subdirectory w/ Joomla

    Ignore this post, problem solved!
    Last edited by zisiadism67; 02-17-2011 at 05:12 PM.

+ Reply to Thread

Similar Threads

  1. Problem with root directory
    By suhaib in forum Programming Help
    Replies: 3
    Last Post: 06-08-2008, 12:46 AM
  2. Cant installed in my root directory
    By mhine in forum Free Hosting
    Replies: 4
    Last Post: 04-11-2008, 07:19 PM
  3. Replies: 3
    Last Post: 09-21-2007, 01:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers