23550 Posts in 19336 Topics by 2890 members
|Go to End|
28 December 2011 at 8:44pm
We would like to switch from using nested URLs to flat URLs to enable greater flexibility in moving pages around the site tree without destroying their URL.
I can see that it is easy to disable nested URLs by removing:
from the config.php file.
However unlike when switching TO nested URLs the redirects do not appear to be handled automatically. Is there a way that we can configure SS to redirect the old nested URLs to the flat ones? or do we have to use the .htaccess file? If so any code hints would be much appreciated.
2 January 2012 at 11:25pm
Have you found solution for this ?
3 January 2012 at 9:24pm
No I haven't unfortunately.
Any help would be much appreciated.
3 January 2012 at 10:48pm
There's no inbuilt support for this, but it should be relatively easy to implement. Just create a custom front controller which pops the last part off the request URL, checks for a SiteTree record with a matching URLSegment, and then redirects to there.
4 January 2012 at 12:07am
Thanks so much for replying here. From what I understand you wrote the code to handle hierarchical URLs in the first place! Fantastic stuff.
I'm not too familiar with the inner workings of SS
Would you be able to provide any hints with the coding as you are most likely more familiar than most when it comes to this area? Or could you point me in the right direction for creating 'custom front controllers'?
4 January 2012 at 12:39am
Maybe take a look at https://github.com/ajshort/silverstripe-linkmapping/blob/master/code/controllers/LinkMappingFrontController.php and the related code in _config.php. The code is a bit hacky, but works. Instead of the LinkMapping::get_by_link() call in the main function, you would want to perform your lookup for a SiteTree object which has a URLSegment matching the last part of the requested URL.
4 January 2012 at 11:49pm
Thanks for getting back to me. Your help on the matter is very much appreciated. I have spoken with our developer and he should be able to figure it out based on the info you've provided.
I'll let you know how it works out and the solution we reach in order to help any others trying to achieve the same thing.
|Go to Top|