cancel
Showing results for 
Search instead for 
Did you mean: 

magento styles doesnt work on controller page (wrong link to css)

magento styles doesnt work on controller page (wrong link to css)

Hello. 

I am using magento 2 with a custom theme. When I try create new controller with action it loads fine but all css/js links on that page looks not correct and not loading. 

 

Code of Index.php

<?php

namespace TestProject\HelloWorld\Controller\Index;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;

class Index extends Action implements HttpGetActionInterface
{
    public function execute()
    {
        return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
    }
}

When I load default pages (for example homepage) CSS styles links looks like this (CustomTheme/WorkTeam - it is a name of the my custom theme)

/static/frontend/CustomTheme/WorkTeam/en_US/css/styles-m.css

but from my helloworld/index/index all links on CSS and JS files have 

/static/frontend/_view/en_US/css/styles-m.css

Code generate wrong path with "_view" in link and those files not loading. What I am doing wrong?

 

Duke

 

 

1 REPLY 1

Re: magento styles doesnt work on controller page (wrong link to css)

You just need to update the apache2.conf file.

 

On Ubuntu 16.04

1. Open and edit the file /etc/apache2/apache2.conf

2. Navigate to the place in the apache2.conf file

3. Change ""AllowOverride None"" to ""AllowOverride All""

4. Save the file

5. Restart apache2 -> sudo service apache2 restart.

If issue solved, Click Kudos & Accept as Solution.
LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool