15

I installed Magento successfully, but the Admin page gives error: 404 not found. Please suggest a solution for this.

The following is the error:

404 Not Found

nginx/1.10.0 (Ubuntu)
4

16 Answers 16

28

For Linux edit the file /etc/apache2/apache2.conf

To edit this file use sudo vi /etc/apache2/apache2.conf command

<Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride None
     Require all granted
</Directory>

to

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

After this run command

sudo service apache2 restart

IF STILL ADMIN SHOW 404 NOT FOUND, FOLLOW THIS STEP

1) Add .htaccess at root of magento 2

https://github.com/magento/magento2/blob/2.3-develop/.htaccess

2) Now run this command

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

rm -rf var/cache/*

rm -rf var/generation/*

4
  • what are you talking about???? nginx ≠ apache
    – MagenX
    Dec 22 '17 at 19:44
  • 1
    Agreed. The OP references Nginx. But as I did have the same problem with Apache 2.4, what I found worked was a) a2dismod rewrite (even though it was enabled!), then b) restart Apache, then c) a2enmod rewrite and then d) restart Apache again. This solved the problem and it was the second time I encountered this on a new install of Apache. And clear cache and pray of course :) Feb 24 '18 at 11:35
  • First two steps fixed my problem, thanks!
    – TawabG
    Sep 1 '19 at 17:35
  • +1 Updating AllowOverride None to AllowOverride All worked for me.
    – Hackinet
    Feb 18 '21 at 15:55
27

Please try Below steps

  1. Delete var/cache folder
  2. Go to database SELECT * FROM core_config_data WHERE path = 'web/seo/use_rewrites' and make it 0
  3. Then enter url in your browser magento_base_url/index.php/your_admin_url

try and let me know if you face any issue.

6
  • What does this web/seo/use_rewrites value do?
    – Niels
    Oct 4 '18 at 9:04
  • 1
    @Niels it will remove index.php from url if it sets to 1 Oct 4 '18 at 10:32
  • @MurtuzaZabuawala Still i am getting same error where i need to focus?
    – zus
    Nov 19 '19 at 10:20
  • @zus please check backend=>frontname in app/etc/env.php file Nov 19 '19 at 13:33
  • @MurtuzaZabuawala I serve magento2.4 using php internal server with command php -S localhost:8080 -t pub, I tried your solution, but still get 404 when request localhost:8080/index.php/magento2/admin_1ibt8z Jul 27 '20 at 4:01
4

Other possible solution is to check for .htaccess file in root directory and add if it doesn't exists (https://github.com/magento/magento2/blob/2.2-develop/.htaccess)

4

I also had this issue, it turned out one of my URLs was set to the IP address and not to the domain name so going to the {domain}/admin was returning not found.

Solution was to run

php bin/magento config:set web/secure/base_url https://domain.com/
php bin/magento config:set web/unsecure/base_url https://domain.com/

Don't forget the trailing slash, it will not work without it https://alanstorm.com/invalid-base-url-value-must-be-a-url-or-one-of/

2
  • this fix worked for me after migrating an old 2.0.15 installation to 2.2.x. During the setup the un-secure url did not have https:// protocol and was the default, the admin url, in the advanced section was configured to use https:// but they BOTH need to be set to be https otherwise page not found issue occurs. Oct 20 '18 at 14:57
  • Yes, thanks, I had too many stores to change and I forgot web/unsecure/base_url where the scope_id is 1 Nov 3 '20 at 14:41
3

Why nobody talk about ?

bin/magento info:adminuri

This will display your adminuri. More info can be found here.

2

Check if the mod_rewrite module is enabled in Apache. To enable mod_rewite module, go to httpd.conf file located at /etc/apache2/httpd.conf and look for "LoadModule rewrite_module libexec/apache2/mod_rewrite.so", if it is commented, then uncomment it by removing # at the front.

1
  • The OP was about Nginx - but as I mentioned above to @Prince Patel, the thing that worked for me was: 1. a2dismod rewrite 2. service apache2 restart 3. a2enmod rewrite 4. service apache2 restart - seems that disabling and enabling rewrite does the job. Feb 24 '18 at 11:37
1

Hope this will help you

bin/magento setup:static-content:deploy Run this command In your CLI

1
  • Curious, how is this a solution for the admin returning a 404?
    – Tisch
    Aug 6 '18 at 8:11
1

First you have to remove content from var/cache and var/session folder ,then change execute this command from commandline/terminal

bin/magento setup:static-content:deploy

1
  • 2
    Curious, how is this a solution for the admin returning a 404?
    – Tisch
    Aug 6 '18 at 8:11
1

I am also same issue. I updated value for "admin/url/custom" to 0 in core_config_data table and my issue resolved.

1

Check if admin/url/custom is empty and admin/url/use_custom is set to 0.

1

I solved this issue after server migration by query db & get custom admin url

Actually my env admin path not working for admin login url

'backend' => [ 'frontName' => 'myadmin' ], http://www.magento.lan/myadmin 404 erorr

Check Admin Url:

bin/magento info:adminuri

Solution:

Step1: First Get Custom admin path

SELECT * FROM `core_config_data` where path like "%admin/url/custom_path%";

Step2: Disable Custom admin Path

Disable from db:

UPDATE `core_config_data` SET `value` = '0' WHERE `core_config_data`.`path` LIKE "%admin/url/use_custom_path%";

Disable from admin:

AdminLogin==>Store=>Configuration=>Advanced=>Admin=>Admin Base URL=>Use Custom Admin Path:=No

I hope it will be save time for someone

0

Just try http://127.0.0.1/ instead of http://127.0.0.1 which worked for me

0

Below is the quick one that I had faced with v2.2.5 and fixed like below.

Go to

cd /your-project-root-folder/app/

and fire

chmod -R 755 etc/
0

I had a similar issue, as well. For me removing the all var folder by: rm -rf var/ and clearing all browser cache: Cmd+Shift+Delete or Command-Shift-Delete for mac, did the trick.

I hope it will help someone!

0

go check you /app/etc/env.php file backend[front_name => admin_kjdfk]. and use this, like base_url/admin_kjdfk

0

Check this for Magento 2.4.3 and Apache 2

sudo subl /etc/apache2/apache2.conf

<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride All
 Require all granted
</Directory>

sudo a2enmod rewrite

systemctl restart apache2

In core_config_data change the web/unsecure/base_url to url + pub/

example

http://mylocal.com.co/magento/magento24 to http://mylocal.com.co/magento/magento24/pub/

delete cache of magento

php ./bin/magento cache:flush

enter image description here

Frontend.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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