Contao Open Source CMS > Enhance > Extension list > [urlcleaner] Remove unwanted elements from the URL 1.0.0 stable

Extensions > urlcleaner

[urlcleaner] Remove unwanted elements from the URL

Removes unwanted parts of the url like "items" or "events"

What it does

All reader modules in Contao (like the news or event reader) get the alias or id of the entry to display as part of the URL. Before that a common part is added to the URL like "/items/" or "/events/". From a users option of view and for SEO this part is unwanted. The extension urlcleaner offers a way to clean the URL from such fragments.

The URL parsing happens in two ways: When a link is generated to such a reader URL, the unwanted part gets removed from the URL. When such a URL is called, the technically missing part is added unseen for the user and search engines in the background.

Usage

After installation of the module you have to modify the localconfig.php for each URL you want to get changed.

Important: Do NOT add a slash at the end of your entries!

Important: Add this code after(!) ### INSTALL SCRIPT STOP ###!

$GLOBALS['TL_CONFIG']['arrUrlFragments'] = array(
  'news-reader' => 'items',
);

This example will rewrite URLs from /news-reader/items/alias to /news-reader/alias. If you want to rewrite multiple URLs, add one line for each in that array. Example:

$GLOBALS['TL_CONFIG']['arrUrlFragments'] = array(
  'news-reader' => 'items',
  'event-reader' => 'events',
);

You can rewrite for more that one level. Let's assume you have a blog entry reader at /weblog/reader/ and the items URLs would be /weblog/reader/items/alias. You can change that to /weblog/alias by the following configuration:

$GLOBALS['TL_CONFIG']['arrUrlFragments'] = array(
        'weblog' => 'reader/items',
);

Important

While expanding URLs the extension checks if there is a page with that alias before expanding it. If this is the case, the additional part won't be added to the URL.

With the last example above:
/blog/foobar is a page (with extension folderurl installed)
/blog/reader/items/foobar would be the regular URL for the blog entry

Each link to /blog/reader/items/foobar will be replaced by /blog/foobar. But when calling /blog/foobar it won't get expanded to /blog/reader/items/foobar because a page with that alias exists. You have to make sure that the aliases you use don't match the aliases of other existing pages.

Avoid duplicate content

When you are using urlcleaner all internal links within Contao are replace to new ones. But the old URLs still remain valid, that means you can call them to get identical content like from the new URLs. This is called duplicate content and is bad for ranking in search engines result pages.

To avoid duplicate content you need to redirect all old URLs to the new ones by an entry in the .htaccess files. Here are some sample rules:
RedirectMatch 301 ^(.*)/newsreader/items/(.*) $1/newsreader/$2
RedirectMatch 301 ^(.*)/eventreader/events/(.*) $1/eventreader/$2

If all occurrences of URLs with the parameter "items" are redirected using urlcleaner, you can put this into one single rewrite rule:
RedirectMatch 301 ^(.*)/items/(.*) $1/$2

Sponsor

The development of this extenion was payed by: http://kurvenkoenig.de

Version1.0.0 stableTypeFree
Release date2010-01-19CategoryOther
LicenseLGPL
Copyright© 2011 Jan Theofel, 2010-2011 ETES GmbH
AuthorJan Theofel (jan.theofel) http://www.theofel.de/
Release notes and change log for 1.0.0 stableOther versions

- Bugfix for ticket #1000: No error message if no configuration is given

1.0.0 beta1
1.0.0 beta2
1.0.0 beta3
Release functionality Total functionality
10.00
Release usability Total usability
10.00
Release quality Total quality
9.00
Release rating Total rating
9.67 (1 votes)
Release downloads109Total downloads124
Release installs696Total installs754
Release updates64Total updates67
Dependencies of this extensionOther extensions depending on this one
NameVersion fromVersion to
Contao2.9.2 stable2.10.4 stable
NameVersion fromVersion to
PackageSizeDate
Contao_urlcleaner_10000009_15.zip74442012-01-15 22:04