Support Joomla!

1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 73 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow FAQs

How do I implement the core Search Engine Friendly URLs (SEF)?
Author(s):SakaExperience level:Intermediate
Contributors:Joomla! version:1.0
Date added:Monday, 28 May 2007Date last changed:Monday, 28 May 2007
 
Since version Joomla! 1.0 Search Engine Friendly URLs are implemented.

SEF is for Apache only. It is using mod_rewrite for pointing server to the right file whilst all logic is in PHP. There are only 3 lines in .htaccess for mod_rewrite directions.

To turn SEF support ON:
1) You must run Apache
2) You must have mod_rewrite enabled
3) Your server must allow .htaccess override
4) Set $mosConfig_sef= "1" in configuration.php
5) Rename htaccess.txt to .htaccess

You will notice that sections/content/items have nice URLs like:
http://www.site.com/content/view/5/2/
and components have URLs like:
http://www.site.com/component/option,com_contact/Itemid,3/

Troubleshooting
If you experience problems with SEF, please make sure you triple-checked these troubleshooting steps:
1) You must run Apache
To check this go to administration > System > System Info. Server type should be listed next to Web Server. SEF will not run on IIS, so don't bother trying.
2) You must have mod_rewrite enabled
To check this go to administration > System > System Info. Click on PHP Information tab. Scroll down until you find Loaded Modules row. mod_rewrite should be listed here. If it's not ask your web host to activate mod_rewrite.
3) Your server must allow .htaccess override
To check this delete everything from your .htaccess file and write a simple command here, for example:
Code:

 
Redirect /google.html http://www.google.com


Now point your browser to http://www.yoursite.com/google.html
If it redirects you to Google.com then you are OK.
4) Set $mosConfig_sef= "1" in configuration.php
You can also activate SEF under Site > Global Configuration.
5) Rename htaccess.txt to .htaccess
This can be done with a FTP program. Note the dot in the beginning! Also note that you can't do this on windows, you must rename it directly on server.

Information for component developers:
What you have to do in order to SEF enable your CMTs (Components/Modules/Templates):

You must convert all links in CMTs to SEF links. This is done with a function called sefRelToAbs().

Example:
Before you had link or form pointing to:
index.php?option=com_contact&Itemid=$Itemid
Now you just do this:
echo sefRelToAbs("index.php?option=com_contact&Itemid=$Itemid");

This will transform this relative URL to link like:
http://www.domain.com/component/option,com_contact/Itemid,3/
Now mod_rewrite will point Apache to index.php and sef.php will do the back-transforming magic.
This function will just return the same link if SEF are disabled so it's safe to code your CMTs with it from now on.

Note that SEF is turned OFF by default and no changes in any way are needed if you are running the CMS the old way, without SEF.

Please make sure that you have right settings before posting that it doesn't work. I will be deleting all comments from people that haven't checked above 5 steps. So: check your php-info and make sure you run Apache and mod_rewrite module is loaded. Make sure you renamed htaccess.txt to .htaccess and that you turned SEF on in configuration.php.




Mod note: There are also several third party extensions which implement search engine friendly URLs. They can be found on the extensions site.
http://extensions.joomla.org/component/option,com_mtree/task,listcats/cat_id,1803/Itemid,35/
Last Updated Monday, 28 May 2007
< Prev   Next >

Powered by EasyFAQ © 2006 Joomla-addons.org