It seems now Magento will only load from pub folder. By default it will not be possible to load it from the root of Magento.
So the best solution for this is to create a virtual host and point it to pub directory.
Alternative
Meanwhile, as an alternative to run this on local machine I tried something else that seems to be working fine with the default setup. Like earlier we were using the base_url
as http://127.0.0.1/magento
. So instead of this now we need to use http://127.0.0.1/magento/pub
as the base_url
. Secure and Unsecure URL needs to be setup on the basis of this.
Setting this up will avoid the issue of 404 page coming.
Note: Verified this with the default Magento only. Not sure for the projects having much complex functionalities. But you can give this a try.
We have another option without adding /pub follow below steps
1. Copy .httaccess file from pub folder and override it to root .htaccess file
2. Upload pub/index.php file to root magento directory
3. Add below code in app/etc/env.php file
'system' => [
'default' => [
'web' => [
'unsecure' => [
'base_media_url' => '{{secure_base_url}}pub/media/',
'base_static_url' => '{{secure_base_url}}pub/static/'
],
'secure' => [
'base_media_url' => '{{secure_base_url}}pub/media/',
'base_static_url' => '{{secure_base_url}}pub/static/'
]
]
]
],
Best Answer
As @Diana Suggest, I create virtual host to run m2.4.2-ee
For that follow the below steps :
1. Copy .conf file for virtual domain :
2. After that, edit your example.com.conf file using this below commad :
and then, paste the below code :
3. After that, you need to enable site using below command :
4. Then, setup your host file using this command :
and add 127.0.0.1 example.com line like
5. update url in core_config_data table :
6. In last, restart your apache server :
Why this type of issue faced?
It's because, everything is running from pub folder in new version. You can check m2.4.2-ee or m2.4.2-ce .htaccess file
There are major difference in new .htaccess and old version .htaccess file. If you replace old version's .htaccess file then, still you can't running proper.
So, Virtual host is only one solution for now. Using this solution, you can run your new m2.4.2 version and also old version of Magento if you have installed already.
Hope, it will useful for you.
Reference : Click Here