This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
@mrmlnc
Hey, friends!
You wouldn't like to consider idea of integration of URL aliases?
I found «REDIRECTION» plugin, but as it seems to me, it not that. For example, as it is organized in PageKit CMS. There is a close connection between pages of CMS and «plugin». The page changes the address (routing).
justas.raudonius23340
Hello, @mrmlnc,
you could create your own settings page for adding aliases and a middleware for serving aliased pages. Here's an example of middleware code:
<?php
namespace My\Plugin\Classes;
use App;
use Closure;
use Cms\Classes\Controller;
class CustomRedirectMiddleware
{
protected $aliases = [
'page1-alias' => 'page1',
'page1-alias2' => 'page1',
'page2-alias' => 'page2',
];
public function handle($request, Closure $next)
{
$path = request()->path();
if (isset($this->aliases[$path])) {
return App::make(Controller::class)->run($this->aliases[$path]);
}
return $next($request);
}
}
Instructions on how to register middleware can be found here: http://octobercms.com/docs/plugin/registration#registering-middleware
1-2 of 2