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

asked Oct 19, 2021 at 8:25
4
  • Can you please share your virtual site's conf file? Commented Oct 19, 2021 at 9:17
  • 1
    @RohanHapani, Update Virtual Host Setting Commented Oct 19, 2021 at 9:26
  • rohanhapani.com/… Just make sure that all steps proper added. Commented Oct 19, 2021 at 9:33
  • @RohanHapani, Yes, its same Commented 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.

answered Oct 19, 2021 at 10:27
3
  • We are using apache and mod_rewrite is enabled but still face the same error. Commented Oct 19, 2021 at 10:52
  • 1
    can you check whether you didnt miss anything from the mentioned configuration. devdocs.magento.com/guides/v2.4/install-gde/prereq/… Commented Oct 19, 2021 at 11:18
  • Thank you it's working. Commented Oct 19, 2021 at 12:16
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);

answered Oct 19, 2021 at 10:39
2
  • Yes I had tried the same but its not work. Commented 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 Commented Oct 20, 2021 at 4:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.