Magento 2 : Error 404 not found at magento 2 admin login page
-
13-12-2019 - |
Question
I have installed magento 2 into my Personal Computer. It working fine over there.
I have installed same copy at another system then frontend is working fine admin is not. (its showing 404 page)
Right now I want to install it into my laptop.
I did following...
I just copy magento2 folder from my PC i.e
wamp/www/magento2
and put it at proper destination into laptop i.ewamp/www/magento2
I export magento2 database from PC and import at Laptop localhost.
Update the
base_url
into imported DB.Deleted contents unders
var/
as wel aspub/static/
I tried following...
- run
php magento setup:upgrade
but not useful.
Solution
This is a general error, usually occurs when you transfer your magento-2 installation from one location to another.
The reason behind this error is that the value store_id
and website_id
for the admin should be 0
, but when you import the database to a new server, somehow these values are not set to 0
.
So to solve this error you will need to make some changes in the database tables itself.
SET FOREIGN_KEY_CHECKS=0;
UPDATE store SET store_id = 0 WHERE code='admin';
UPDATE store_group SET group_id = 0 WHERE name='Default';
UPDATE store_website SET website_id = 0 WHERE code='admin';
UPDATE customer_group SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
OTHER TIPS
add these line in .htaccess
<IfModule mod_rewrite.c>
############################################
## Enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## You can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
############################################
## Workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## Never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## Rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Don't do anything, just check the .htacess file at the root directory. If it's already there, rename it and use the default on and if it's not there then use the default one. Clear your cache / flush your cache and here you go