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?

 
 
 
4 REPLIES 4

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

Re: Issue with Routes and CSS in Magento 2

Hey there,

It sounds like your Magento 2 issue might be related to either static file deployment or URL rewrites. When routes and CSS/JS aren’t loading properly, a few things you can check are:

  1. Deploy Static Content:
    Try running this from your Magento root directory:

    bash
    CopyEdit
    php bin/magento setup:static-content:deploy -f
  2. Check .htaccess / URL Rewrites:
    Make sure your web server (Apache/Nginx) is correctly handling URL rewrites. Magento 2 needs mod_rewrite enabled in Apache, and your .htaccess files must be properly in place.

  3. Set the Correct Base URL:
    Sometimes the base URL gets misconfigured. Run:

    bash
    CopyEdit
    php bin/magento setup:upgrade php bin/magento cache:flush

    Then check in your database (core_config_data table) that the web/unsecure/base_url and web/secure/base_url are properly set.

  4. Permissions Issue:
    Ensure pub/static, var, and generated folders have the correct permissions.

  5. Developer Mode:
    If you’re working locally, switching to developer mode can help:

    bash
    CopyEdit
    php bin/magento deploy:mode:set developer

Also, make sure you cleared your browser cache after any changes!

If Magento 2 feels like solving puzzles inside a Pokemon games sometimes, you’re not alone — but don’t worry, we’ll get you to the next level! 
Feel free to share any error logs or more screenshots if you’re still stuck!