0

I have created my custom module for loading the custom template.

Here is the code of Vendor/Module/etc/frontend/routes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
<router id="standard">
    <route id="customname" frontName="customname">
        <module name="Vendor_Module" />
    </route>
</router>

then Vendor/Module/Controller/Index/Index.php

<?php

namespace Vendor\Module\Controller\Index;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
class Index extends \Magento\Framework\App\Action\Action
{

    public function execute()
    {
        $this->_view->loadLayout();
        $this->_view->getLayout()->initMessages();
        $this->_view->renderLayout();
    }
}

Vendor/Module/view/frontend/layout/customname_index_index.xml

<referenceContainer name="content">
            <block class="Vendor\Module\Block\Index\Index" name="customname_index_index" cacheable="false" template="Vendor_Module::customname_index_index.phtml"/>
</referenceContainer>

So here my question is to view my template file, I am forming url like below.

website.com/customname/index/index/

Here i am looking for how to make the url as seo friendly?

Is there any possibility to achieve this?

Anyone can look into it and update your thoughts. Thanks

  • use custom route – Amit Bera Jul 23 at 14:56
  • @AmitBera, can you please elaborate as answer – Manjunath Jul 23 at 14:58
  • Just add a URL rewrite for your controller url – Milind Singh Jul 23 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.