0

Current, We are using Magento242 With Virtual host, Somehow display the wrong path for CSS, js, and media file

Correct Path: https://example.com/pub/static/frontend/Mgs/claue/en_US/mage/calendar.css

Wrong Path: https://example.com/static/frontend/Mgs/claue/en_US/mage/calendar.css

Pub folder does not include in CSS, JS URL

Please let me know if anyone has faced the same issue.


Virtual Host

enter image description here


Web Url

enter image description here

4
  • Can you please share your virtual site's conf file? Oct 19, 2021 at 9:17
  • 1
    @RohanHapani, Update Virtual Host Setting Oct 19, 2021 at 9:26
  • rohanhapani.com/… Just make sure that all steps proper added. Oct 19, 2021 at 9:33
  • @RohanHapani, Yes, its same Oct 19, 2021 at 9:37

2 Answers 2

0

@ravi dudhara - Dont keep /pub/ in the document root section at virtual host file. I am not sure what is the web server you are using.

If you are using nginx, please include the sample nginx config file in your virtual host file and ensure the url rewrite related nginx [ ngx_http_rewrite_module] modules are enabled.

In case if it is apache, it will automatically take the .htaccess file and do the necessary url rewrite. you need to make mod_rewrite module is enabled on the server.

3
0

did you try with this code ??

i have remove pub/

sudo gedit /etc/apache2/sites-available/example.conf

Add lines :

ServerName example.local

ServerAlias www.example.local

DocumentRoot /var/www/html/example/pub

Step 2

sudo a2ensite example.conf

sudo systemctl reload apache2

sudo gedit /etc/hosts

sudo service apache2 restart

step 3

insert the code in Database

insert core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0);

2
  • Yes I had tried the same but its not work. Oct 19, 2021 at 11:03
  • @RaviDudhara please go this location pub/static and check .htaccess (hidden file). if this file not exist, you can copy same file another project and past it. and then run all comamnds again. php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php biin/magento cache:flush
    – Gaurav
    Oct 20, 2021 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.