Redirect Root Directory to Subdirectory w/ Joomla

caiol611

New Member
Messages
7
Reaction score
1
Points
0
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:

Sohail

Active Member
Messages
3,055
Reaction score
0
Points
36
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:

JKnife

New Member
Messages
49
Reaction score
0
Points
0
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:

Sohail

Active Member
Messages
3,055
Reaction score
0
Points
36
Thanks, i think the PHP way is better, it's simple and easy to change...
 

CypressBlade

New Member
Messages
1
Reaction score
0
Points
0
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!
 
Top