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
Web Url
- 
 Can you please share your virtual site's conf file?Rohan Hapani– Rohan Hapani2021年10月19日 09:17:28 +00:00Commented Oct 19, 2021 at 9:17
- 
 1@RohanHapani, Update Virtual Host SettingRavi Dudhara– Ravi Dudhara2021年10月19日 09:26:40 +00:00Commented Oct 19, 2021 at 9:26
- 
 rohanhapani.com/… Just make sure that all steps proper added.Rohan Hapani– Rohan Hapani2021年10月19日 09:33:07 +00:00Commented Oct 19, 2021 at 9:33
- 
 @RohanHapani, Yes, its sameRavi Dudhara– Ravi Dudhara2021年10月19日 09:37:01 +00:00Commented Oct 19, 2021 at 9:37
2 Answers 2
@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.
- 
 We are using apache and mod_rewrite is enabled but still face the same error.Ravi Dudhara– Ravi Dudhara2021年10月19日 10:52:00 +00:00Commented Oct 19, 2021 at 10:52
- 
 1can you check whether you didnt miss anything from the mentioned configuration. devdocs.magento.com/guides/v2.4/install-gde/prereq/…Thamo– Thamo2021年10月19日 11:18:25 +00:00Commented Oct 19, 2021 at 11:18
- 
 Thank you it's working.Ravi Dudhara– Ravi Dudhara2021年10月19日 12:16:19 +00:00Commented Oct 19, 2021 at 12:16
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);
- 
 Yes I had tried the same but its not work.Ravi Dudhara– Ravi Dudhara2021年10月19日 11:03:11 +00:00Commented 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:flushGaurav– Gaurav2021年10月20日 04:33:09 +00:00Commented Oct 20, 2021 at 4:33