cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Routes and CSS in Magento 2

Issue with Routes and CSS in Magento 2

Guys, I'm having a problem. Magento 2 runs, but the routes don't work, and neither do the CSS files, as shown in the pictures below.

 

 

Could someone help me figure out how to fix this?

 
 
 
3 REPLIES 3

Re: Issue with Routes and CSS in Magento 2

Hi.

Have you run the deployment commands yet?
Check the logs in Magento and the Network tab in the browser.

Mageplaza | Top-Rated Magento Extension and Solution Provider


Should you have any questions or concerns, feel free to contact us via consultant@mageplaza.com

Re: Issue with Routes and CSS in Magento 2

Hi !
It sounds like you're facing an issue in Magento 2 where the routes aren't working, and CSS files are not loading correctly. This could be due to a variety of reasons, including cache issues, misconfigurations in routes or static files, or missing file permissions. Let's go through some troubleshooting steps to resolve these problems.

 

  • Clear Magento cache and redeploy static files.

  • Check your route configuration (routes.xml) for correctness.

  • Ensure correct file permissions for pub/static and var folders.

  • Verify .htaccess or nginx.conf settings for static file and route handling.

  • Enable Developer Mode for more detailed error messages.

  • Check the browser console for missing or incorrect static file paths.

  • Disable third-party extensions if the issue persists.

 

1# Best Magento 2 Page Builder Extension | Easy Drag & Drop

Re: Issue with Routes and CSS in Magento 2

Hello @joaobatist2394,

 

Well you posted picture is not visible to me.

I am guessing that you are only able to see home page, if you visit any other pages it gives error of no route match etc.

There are suggestions below which you can check:

1. Apache requires the mod_rewrite module to handle URL rewrites

sudo a2enmod rewrite
sudo systemctl restart apache2

2. Magento 2 uses .htaccess for URL rewriting. Make sure your Apache server is properly handling .htaccess files and that the file is present in your Magento 2 root directory. The .htaccess file should have the necessary directives for rewrites.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/pub/.*$
RewriteCond %{REQUEST_URI} !^/var/.*$
RewriteRule ^(.*)$ index.php [QSA,L]

3. You need to make sure that the Apache virtual host is configured to allow .htaccess overrides. Look for the AllowOverride directive in your Apache virtual host configuration.

For example, your 000-default.conf or custom .conf file might look like this:

<VirtualHost *:80>
    DocumentRoot /var/www/html/magento2
    ServerName example.com
    <Directory /var/www/html/magento2>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

4. Make sure your Magento installation has the correct file permissions.

 

I hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy