ez.no / ezpublish / documentation / customization / tips & tricks / creating nice urls
These documentation pages are no longer maintained. Please visit the new documentation site.
Well, take a look at the ez.no site and you will notice that the URL's are formed with a nice descriptive path and without the index.php and /content/view/full/id like in the demo setup.
The demo setup is general for both non-virtual host and virtual host setups. Therefore it always includes the index.php script.
First of all, you need to have a virtual host based setup with the proper rewrite rules. See the install section for a detailed description.
Then you need to search for instances of the ezurl operator in the templates and change it to ezroot instead. The latter does not include the index.php in the resulting URL. If you create your own templates, just use ezroot for URL assembling.
First you need to change NodeTranslation in [URLTranslator] to enabled in your /settings/override/site.ini.append.php or in the siteaccess override for your /settings/siteaccess/yoursite/site.ini.append:
[URLTranslator] # Use either enabled or disabled Translation=enabled # Enable this if you want to percieve the url as a path element # for the node tree. By entering the path in the url and ending it # with a .html you will get the correct node. NodeTranslation=enabled
The next step is to change your templates to use the url_alias field for the requested node in actions like /content/view/full in the build up of urls (and use the ezroot operator instead of the foul-proof ezurl operator if you did not already do this).
For example change
<a href={concat("/content/view/full/",$Folder:item.node_id,"/")|ezurl}>{$Folder:item.name|wash}</a>
to
<a href={concat("/",$Folder:item.url_alias)|ezroot}>{$Folder:item.name|wash}</a>
As always when changing templates, clear your cache to see the results or turn off caching altogether.
You can use nice urls with url_alias in all instances where you have a /content/view action. So pagelayout.tpl and the overrides for sections are the place to start. Next you can change the overrides for the full_class_[id] for folder or folder like objects.
Better not use the url_alias in actions other than
/content/view/<full|list...>
since you may break some functionality in for example creating new objects (where url_alias does not make sense since the node has no name yet).
Comments
About 'nice URL's'
Tatiana Vorob'eva
Tuesday 21 June 2005 6:36:33 pm
But it shows the titles of site pages in translite from russian into english.
What I've done wrong?
Please. Help. :)
re:nice url to subfolder does'n work
adrien gibrat
Tuesday 21 June 2005 3:59:36 am
just add following lines to .htaccess:
RewriteEngine On
RewriteRule ^([^.]+)/?$ /index.php/$1
see final look (Once again)
nice url to subfolder does'n work
rombeh rorombeheun
Thursday 03 March 2005 5:44:22 pm
RewriteEngine On
RewriteRule ^([^./]+)/?$ /index.php/$1
it's work when I access url aliases point root subdirectory (ex: www.site.com/news), but when I try to access next directory level (www.site.com/news/thisnews) the system can't find the page.
any help...?
thanks
broken link
Terry Grossman
Sunday 25 July 2004 7:41:21 pm
the link (in the article) to the install section doesn't work anymore
Don't forget to change ezurl to ezroot for link tags
Joel Hardi
Thursday 13 May 2004 9:29:11 pm
<a href={$href|ezurl} {section show=$target}target="{$target}"{/section}>{$content}</a>
to
<a href={$href|ezroot} {section show=$target}target="{$target}"{/section}>{$content}</a>
(This example based on 3.3-4 ... if you have a different version your link.tpl might be slightly different.)
Once again
Mike Borozdin
Saturday 10 January 2004 4:05:26 pm
---
RewriteEngine On
RewriteRule ^([^.]+)?$ /index.php/$1
---
Sorry
Mike Borozdin
Saturday 10 January 2004 4:01:12 pm
---
RewriteEngine On
RewriteRule ^([^./]+)?$ /index.php/$1
---
mod_rewrite
Mike Borozdin
Saturday 10 January 2004 3:58:39 pm
---
RewriteEngine On
RewriteRule ^([^./]+)/?$ /index.php/$1
---