joomla/joomla-cms — pull request #3855 by zjw (2014-07-02 22:19:53+00:00)
Title: Permit relative "Expired URLs" in the Redirect component/plugin

(Joomla Feature tracker: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33918&start=0)

Currently, only full URLs are searched for amoung the "Expired URLs" entered in the Redirect component. This PR permits the matching of relative path URLs entered in the component as well.

__Advantages:__

Joomla! sites accessible with http and https don't need to enter separate redirects for each scheme.

Joomla! sites accessible via multiple domain names don't need to enter separate redirects for each domain.

If an entire Joomla! site is relocated, the redirects for the site don't need to be rewritten based on the new location.

__Changes:__

When editing a redirect in the component, the tool tip for the source URL has been updated.

When viewing the list of redirects in the component, the entire "Expired URL" is displayed just as it was entered. Previously, the Joomla! root of the path was hidden. Now, if a full URL was entered, the full URL is displayed. If only a relative path was entered, only the relative path is displayed.

In the plugin, a search for a redirect match is first made using the full URL. If no match is found, the the full URL is modified by removing the Joomla! root (if it exists), and a second search is performed for a matching relative path.

When no match is found, the behavior has slightly changed. The old behavior was to always add the full URL to the list of redirects. The new behavior is to add a relative path URL to the list of redirects if the full URL begins with the Joomla! root.

__To test:__

Install the patched version of Joomla! on an apache server with some sample data.

For example, assume the base installation is located here:

http://example.com/index.php

In the site configuration, enable:

Search Engine Friendly URLs
Use URL rewriting
Adds Suffix to URL

Enable the System/Redirect plugin

copy htaccess.txt to .htaccess

In the Redirect component, create a redirect with a relative path as the source/expired URL:

foo/bar/missing.html -> http://example.com/index.php

Visiting the expired URL (http://example.com/foo/bar/missing.html) should properly redirect.

Attempting to access an non-existant URL (e.g., http://example.com/foo/bar/also_missing.html) should automatically create an expired URL in the redirect component which is stored as a relative path (foo/bar/also_missing.html).