SEF URLs
User Manual » Troubleshooting » SEF URLs
TangoCMS has the ability to use 'SEF', Search Engine Friendly, URLs which means a typical URL will look like 'article/index/general' instead of 'index.php?url=article/index/general'. For this to work the server must be configured correctly to allow for it, other wise you will simply get a 404 Page Not Found error from your webserver.
There is basic detection within TangoCMS to check if this functionaility will be possible, and if not it will revert to the 'standard' router. However this can fail under certain conditions, and the check is only available if PHP is running as a module to Apache.
Ensure the configuration is set to 'sef' router
The first change you may need to do is ensuring the configuration file (config.ini.php) is set to use the 'sef' router type, instead of 'standard'. To do this, edit the file 'config/default/config.ini.php' and find the following lines (around line 41):
[url_router]
type = standard
Simply change the word 'standard' to 'sef' (no quotes), and TangoCMS will now attempt to use SEF URLs. If when going to a URL you now get a 404 page from your webserver, you'll need to follow the following sections below.
Reasons for SEF not working
- You have forgotten to upload/move the '.htaccess' file. This is the most common reason because it is a hidden file on majority of operating systems (though not Microsoft Windows).
- Apache module 'mod_rewrite' is not installed/enabled.
- Your Apache configuration is not setup to allow the rewrite rules to be applied.
- You're not using Apache, and so the rewrite rules wont even be read.
Enabling and Configuring Apache module 'mod_rewrite'
On Debian based systems, there is the tool 'a2enmod' which will let you enable the needed module quickly, such as:
sudo a2enmod rewrite
The module should now be enabled (shown by the message 'Module rewrite installed; run /etc/init.d/apache2 force-reload to enable.') and Apache will need to be restarted for the module to be loaded. Doing as the message says, use the following to restart Apache:
sudo /etc/init.d/apache2 force-reload
If you're not using a Debian based operating system, you'll need to edit your Apache2 config file which is most commonly called 'apache2.conf' or 'httpd.conf' and make sure there is a line similar to the one below (note there is no # in the front of it!)
LoadModule rewrite_module modules/mod_rewrite.so
Configuring Apache to allow for the 'rewrite' rules
If still after installing the Apache module 'mod_rewrite' you are still getting the Clean/SEF URL's error then the problem could be due to your Apache configuration. Open up your configuration file (for example /etc/apache2/apache2.conf or /etc/apache2/sites-available/default) and find the 'AllowOverride' directive then make sure it is set to 'All', so for example:
AllowOverride +All
As you've made a change to the Apache configuration, you must now restart Apache for the changes to take effect.
sudo /etc/init.d/apache2 restart
Lighttpd
Users of lighttpd will need to edit their configuration file, and add in the following rewrite rules (ensure the 'rewrite' module is enabled first!):
## TangoCMS Rewrite Rules
url.rewrite-once += (
"^/(?:install/themes|tmp|assets(?!(/v/|/js/tinymce/tiny_mce_gzip\.php)))/.*?$" => "$0",
"^/install/(.*)$" => "/install/index.php?url=$1",
"^(?:$|/((?!(?:(?:index\.php.*?|favicon\.png|robots\.txt))).*?)?(?:\?(.*))?$)" => "/index.php?url=$1&$2"
)
Restart Lighttpd and SEF should now work correctly.
nginx
Edit the main configuration file for your nginx webserver, and use the following to enable URL rewriting that TangoCMS will need:
location / {
## TangoCMS Rewrite Rules
if (!-e $request_filename) {
rewrite ^/?(.+)$ /index.php?url=$1 last;
}
location ~* /(application/logs/.*?\.log|tmp/cache|/config|\.svn)(/|$) {
return 403;
}
}
Restart your webserver and SEF should now work correctly.
Failsafe router type
If you are unable to resolve the issue that is stopping SEF URLs from working, then you will have to change the 'router' type to the failsafe 'standard'. To do this, edit the file 'config/default/config.ini.php' and find the following lines (around line 41):
[url_router]
type = sef
Replace the 'type' to 'standard' instead of 'sef', it should now read:
[url_router]
type = standard
Once this is done, the URL structure should now change and you will be able to use TangoCMS without the SEF (Search Engine Friendly) URLs.