Results 1 to 9 of 9

Thread: Joomla 1.5 in a subfolder using htaccess redirect

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Default Joomla 1.5 in a subfolder using htaccess redirect

    Hi All,

    I'm posting this tutorial here because I wrestled with this issue for days (!!!) before finding an actual working solution.

    Basically the issue is that I'm hosting multiple websites inside a single HostMonster account. And while you can point add-on domains to whatever subfolder you choose, the default domain in the account is pointed to the public_html folder and cannot be changed.

    However, to keep everything neat and tidy, I want each site to be in a subfolder (for example: Site 1 in public_html/site1, Site 2 in public_html/site2, and so on), but I don't want the subfolder to show in the URL. In other words I want to mask the subfolder.

    There are two steps to the process, and the second one is important when running Joomla 1.5.x (other CMS like Drupal may not be affected), otherwise the subfolder name will show in the site's URLs....

    STEP 1:

    First, we must redirect to the subfolder and mask URL. So, your domain is domain.com, which by default points to public_http, and you want it to go to the public_http/joomla2 subfolder instead. We do this using a .htaccess file placed in public_http. Copy and paste the following code into this file, and edit it per the instructions within.


    Code:
    # Hostmonster.com
    # .htaccess main domain to subfolder redirect
    # Copy and paste the following code into the .htaccess file
    # in the public_html folder of your hosting account
    # make the changes to the file according to the instructions.
    
    # Do not change this line.
    RewriteEngine on
    
    # Change yourdomain.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$ [NC]
    
    # Change 'subfolder' to be the folder you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/subfolder/
    
    # Don't change these lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Change 'subfolder' to be the folder you will use for your main domain.
    RewriteRule ^(.*)$ /subfolder/$1 [L]
    
    # Change yourdomain.com to be your main domain again.
    # Change 'subfolder' to be the folder 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.)?yourmaindomain.com$ [NC]
    RewriteRule ^(/)?$ subfolder/index.php [L]
    * The above code is originally from Host Monster, but has been slightly modified to remove URL case sensitivity.

    STEP 2:

    Next, we must tell Joomla not to include the subfolder in the links it creates within its pages. (i.e. we want http://domain.com/index.php not http://domain.com/joomla1/index.php). We do this by editing the configuration.php file in the Joomla folder, and changing the $live_site variable as follows (NOTE: change domain.com to your actual domain):

    Code:
    var $live_site = 'http://www.domain.com';
    Now, flush your browser cache and history, then try loading your site. If everything was done correctly you should see your site normally, and the URL will not contain the subfolder name.

    Hope somebody finds this useful.

    Cheers!

    -Blitz.

  2. #2

    Default

    This is a fantastic tutorial and I wanted to thank you for the submission. I will post a link to this in the User Submitted Tutorials sticky, but I wanted to ask a question first.

    I haven't tried this on any of my test sites yet, but will this work around break the functionality of any URL rewritting done by either the Joomla! engine itself, or third-party components that rewrite the URLs for Joomla! sites like sh404sef?

    ~regards, and welcome to the community!
    He is no fool that gives what he cannot keep to gain what he cannot lose. - Jim Elliot
    4ChristMinistry.org - Web development tutorials and Community forum.
    Demos - Kicking the tires on some popular software.

  3. #3
    Join Date
    Nov 2008
    Posts
    2

    Default

    Quote Originally Posted by shadmego View Post
    I haven't tried this on any of my test sites yet, but will this work around break the functionality of any URL rewritting done by either the Joomla! engine itself, or third-party components that rewrite the URLs for Joomla! sites like sh404sef?
    I've tried it with the basic Joomla SEF and Artio's JoomSEF, both of which require an .htaccess file in the joomla folder, and they both work just fine.

    According to the info I've read, the $live_site variable was added to Joomla! around 1.5.2 specifically to deal with the problem of different URL and disk paths. Some older components that use deprecated methods of determining the base URL may not work, so I've read.

    Enjoy!

  4. #4
    Join Date
    Jan 2008
    Posts
    20

    Default

    Very nice tutorial! I will be implementing this as soon as I get the chance! I am currently running almost the exact same setup and it got messy. Now I can make it easier for me and my partner in crime to browser our directories!

  5. #5
    Join Date
    Jul 2008
    Posts
    4

    Default

    Thank you very much, Blitz!
    I just did everything as you described and it works!
    Great!

  6. #6
    Join Date
    Jan 2008
    Location
    Alaska
    Posts
    26

    Default

    It's awesome to find the answer to a question before you even think to ask it. Thank you so much for saving me the days you had to wrestle with this!

  7. #7
    Join Date
    May 2009
    Posts
    1

    Default

    hi, i bumping this thread cause i have an issue related with this...

    i followed all these steps, and it is working as planned, www.colombiaselecta.net (hides /home/ subfolder when i first enter the adress)

    but, every other link on the site still has the /home/ subdirectory on the url. tried cleaning the cache, and asked some other people about this, but they all see the home subdirectory. is there any additional change i need to do on the .htacess file?

    i have the sef urls enabled atm

  8. #8
    Join Date
    Aug 2009
    Posts
    1

    Default Thanks

    I just registered so i can say THANKS FOR BEING SUCH A LEGEND! I just know i would have spent hours messing around with this, but it makes sence now! I would never have thought of the live site varioable in the config!

  9. #9
    Join Date
    Nov 2009
    Posts
    1

    Thumbs up Thank you, thank you, thank you for this!

    I was looking for this info. Great explanation even a newb like me can understand.

    I registered just so I could say thanks.


    Awesome

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
ankara escort show yeri malatya escort erotik film izle adana escort escort eskişehir didim escort escort bayan adult forum porno
rokettube