Home arrow Blog arrow Webdesign arrow Completely hide Joomla subdirectory while using SEF URLs with sh404SEF
Completely hide Joomla subdirectory while using SEF URLs with sh404SEF PDF Drucken E-Mail
(3 Stimmen)
Geschrieben von Jörgi   
Montag, 4. Feber 2008

As I had a hard time finding a solution for this problem, I've decided to write this article in English so that maybe I can help someone out there who wants to reproduce my current Joomla setup.

Introduction 

Let's start with a brief introduction what this tutorial will help you to accomplish. If you have installed Joomla 1.0.x in a subdirectory of your webroot, e.g. mydomain.com/joomla you will be able to completely hide this fact, e.g. all users of your website will think that Joomla is installed directly in the webroot mydomain.com. While this problem is quite easy to solve using a htaccess script, I really wanted to use the awesome Joomla component sh404SEF, which generates great Search Engine Friendly URLs. Unfortunately there are some problems with sh404SEF and my subdirectory hiding method but you can solve them by using another component called Redirect component.

Hide Joomla subdirectory

First of all you have to edit the file joomla/configuration.php. Find the line

$mosConfig_live_site = 'http://mydomain.com/joomla';

and replace it with 

$mosConfig_live_site = 'http://mydomain.com';

Now you have to edit (or create if it does not exist yet) the file .htaccess in your webroot (not the one in the Joomla subdirectory!) and change its content to: 

Options +FollowSymlinks
RewriteEngine on

# Let's get rid of the "www"
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301]

# Redirect to the cms root folder
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^(index\.html)?$ http://mydomain.com/joomla/ [R=301]

# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$

# Only apply to URLs that aren't already under folder
RewriteCond %{REQUEST_URI} !^/joomla/

# 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 ^(.*)$ /joomla/$1 [L]

Of course you have to replace mydomain.com with your domain and joomla to the name of the subdirectory in which you have installed Joomla.

Now your Joomla subdiretory should be hidden from all users. If you don't want to use Search Engine Friendly URLs with sh404SEF you can stop here.

Search Engine Friendly URLs using sh404SEF

First you have to install the component sh404SEF. Download it and install it like any other component (Select Installers -> Components in the menu). If you want really Search Engine Friendly URLs you maybe want to use the option with .htaccess (mod_rewrite) which prevents the string index.php to appear in your URLs. To use this option you have to change the sh404SEF configuration via Components -> sh404SEF -> Configuration -> Advanced and set the Rewriting mode to with .htaccess (mod_rewrite).

Now edit the file joomla/.htaccess (not the one in the root directory!). Comment out everything in the section Joomla! core SEF Section, e.g.:

########## Begin - Joomla! core SEF Section
############# Use this section if using ONLY Joomla! core SEF
## ALL (RewriteCond) lines in this section are only required if you actually
## have directories named 'content' or 'component' on your server
## If you do not have directories with these names, comment them out.
#
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
#RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
#RewriteRule ^(content/|component/) index.php
#
########## End - Joomla! core SEF Section

Then find the 3rd Party SEF Section and uncomment everything there, e.g.:

########## Begin - 3rd Party SEF Section
############# Use this section if you are using a 3rd party (Non Joomla! core) SEF extension
#
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
#
########## End - 3rd Party SEF Section

Now your whole website should use nice SEFs (you can play with the various settings of sh404SEF to change everything according to your preferences). After this step I had one last problem. My "Home" site showed something like

(http://mydomain.com//)
404: Not found

everytime I entered my site or clicked the "Home" link. Fortunately I found a solution for this problem in the sh404SEF support forum.

Solving the '404: Not found' problem 

First you have to install the Redirect component. Then you have to enter a new redirection using this component:

Old URL Leave blank
Redirect to
home.html
Error code
301 Moved permanently

Then go to sh404sef admin panel and click View/Edit SEF URLs. Click NEW icon on top of the screen and enter the following:

New SEF URL
home.html
Non-SEF URLindex.php?option=com_frontpage&Itemid=1

Now everything should work fine! You can browse this website to see how all SEF URLs should look like. Feel free to leave a comment and let me know if it worked for you too! Wink
» 9 Kommentare
1Kommentar
am Freitag, 8. Feber 2008 10:53von Gast
cool!! thank you very much, i've been searching for a long time a way to do this!
2"You're welcome"
am Freitag, 8. Feber 2008 11:01von LauriN
I'm glad I could help you! ;)
3"Good enough for me"
am Dienstag, 26. Feber 2008 07:25von Jonaley
Thanks a lot for this, I looked around the internet for hours before I found it. Not sure why this is such an obscure issue, seems like a of people would want to do this as some hosting companies require CMSs to be installed in sub-directories instead of the root. Anyways, it worked great for me, thanks!
4"lani"
am Montag, 19. Mai 2008 08:17von voca
what if I host 2,3,joomla sites under 1 webhost? Each has different domain name and are stored in their own folder inside the webroot directory. I want to redirect to the appropriate folder for each single one of the domain. Will this work? Thanks
5Kommentar
am Dienstag, 27. Mai 2008 21:56von D. Rich
A better fix is located here: 
http://www.drichproductions.com/r andom-knowledge/rewrite-root-directory-s ubdirectory.php
6"Technoarchive downloads"
am Freitag, 13. Juni 2008 02:20von Technoarchive
Check http://www.technoarchive.com/
7"Mr"
am Montag, 1. September 2008 18:11von Kev King
Um, must be doing something wrong here, when all the steps are followed it just generates an internal server error 500 and wont display anything, web page or /joomla/administrator.
8"Reichard"
am Mittwoch, 18. März 2009 20:41von Georg
In my case everything worked fine but the plain domain - thus I had to add the following rule at the end of htaccess so that my index file was loaded correctly: 
RewriteRule ^(/)?$ joomla/index.php [L]
9"Web Site Designer"
am Samstag, 4. April 2009 01:38von Raydeen
I can't get it to work...I'm running Joomla version 1.5.9, when I change the config file to http://www.simplyraydeen.com instead of http://www.simplyraydeen.com/joomla, I get the home page but no links work, nor does the admin. My guess is that even though I change the .htaccess file accordingly, it will not work until I can get the configuration file set correctly. Any assistance would be so appreciated. I've been using Joomla for approximately 1 week.
» Kommentar schreiben
E-Mail (wird nicht veröffentlicht)
Name
Titel
Kommentar
 verbleibende Zeichen
Captcha Image Code neu generieren, falls er unlesbar sein sollte
Letzte Aktualisierung ( Montag, 4. Feber 2008 )
 
< zurück

Neueste Photos













Zufallsphotos