FAQ: How do I implement the core Search Engine Friendly URLs (SEF)?

This is the archive off all FAQ related threads.
Locked
User avatar
Saka
Joomla! Explorer
Joomla! Explorer
Posts: 263
Joined: Sat Aug 13, 2005 2:13 am
Location: Sweden
Contact:

FAQ: How do I implement the core Search Engine Friendly URLs (SEF)?

Post by Saka » Wed Aug 24, 2005 11:20 pm

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,co ... /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: Select all

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, ... /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/ ... Itemid,35/

Keywords: sef SEF search engine friendly google htaccess .htaccess htaccess.txt url urls

DISCUSSION THREAD HERE: http://forum.joomla.org/index.php/topic,36384.0.html
Last edited by mcsmom on Sat Oct 14, 2006 1:46 pm, edited 1 time in total.

 
 
Locked

Return to “FAQ Archive”