Alias URL Matching Problem - Unwanted Forwarding to Canonical URL.

Permalink
Hi All,

I have a problem whereby, additional text appended to the end of an alias URL in the browser is still causing a match with the alias URL and so 301 forwarding to the canonical URL, instead of just 404'ing. Example:

Canonical URL: site.com/slug1
Alias of canonical: site.com/slug1/slug2

Now, if I type the following into the browser, I will still be redirected to the canonical, instead of 404'd, despite the URL not matching the stated alias:

site.com/slug1/slug2/slug3/

I understand that this is so one can append URL parameters to the alias, such as:

site.com/slug1/slug2?foo=bar

However, there doesn't seem to be a way to prevent this forwarding from happening, if it's not wanted when the URL doesn't exactly match.

I solved this by making the following adjustments to /concrete/startup/external_link.php

if (($req->getRequestCollectionPath() != '') && ($req->getRequestCollectionPath() != $c->getCollectionPath())) {
      // canonnical paths do not match requested path
      if ('/'.$req->getRequestPath() == $req->getRequestCollectionPath()) {
         header('Location: ' . Loader::helper('navigation')->getLinkToCollection($c, true), true, 301);
         exit;
      }
   }


This way, the user will not be forwarded unless the alias URL exactly matches the requested url.

I accept that this means 'no more URL parameters' on aliases. But they currently fail work anyway (http://www.concrete5.org/index.php?cID=472663) and I don't need them either.

But... is there a better / alternative way to handle this? I realise this is a hack ;)

Cheers,

Richard

 
dexterweb replied on at Permalink Reply 1 Attachment
dexterweb
I'm facing the same issue. Any help would be welcome!

For example: this page: deburen.nu/vacatures
should be re-directed to:http://deburen.nu/over-ons/vacatures...
Big 404..