Labeeb Mohammed
Labeeb Mohammed

Reputation: 76

Magento2 : Admin redirection issue

I have installed Magento2 on my WAMP server. And when I tried to access http://127.0.0.1/magento2/admin/ it's redirecting to http://localhost/admin/admin/dashboard/ (An invalid URL)?

Upvotes: 1

Views: 6015

Answers (14)

Rishabh Tiwari
Rishabh Tiwari

Reputation: 1

The redirected url is correct if it is opening properly

/admin is the default url to open the admin dashboard in Magento

Upvotes: 0

nikhil ajani
nikhil ajani

Reputation: 36

need to enter host entry for local

sudo nano /etc/apache2/sites-available/000-default.conf

Add the path to your Magento pub/ directory to the DocumentRoot directive

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/magento2/pub
         ServerName hostname.magento.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html">
AllowOverride all
</Directory>
</VirtualHost>

sudo systemctl restart apache2

Upvotes: 0

Puneet
Puneet

Reputation: 29

Open Mysql and run below mysql query:

UPDATE `core_config_data` set value = "http://127.0.0.1/magento2/admin/" WHERE path like "%base_url"

After run Mysql query you need to run below command in ssh terminal for flush cache or you can direct delete magento root var/cache folder. After that try to open magento admin it would work.

php bin/magento cache:flush

Upvotes: 0

J.FU
J.FU

Reputation: 1

Check your base_url on database core_config_data table
And also check app/etc/env.php frontName value.
After that:

set module:developer
setup:upgrade
clean cache

Upvotes: 0

Alex
Alex

Reputation: 767

try switch to Developer mode

bin/magento deploy:mode:set developer

Upvotes: 0

Amaresh Tiwari
Amaresh Tiwari

Reputation: 827

I hope it will works!

First you can check the file app/etc/env.php and check backend frontName should be 'admin' like below.

return [
    'backend' => [
        'frontName' => 'admin'
    ],
   ...........
   ...........
   ...........
];

And then run this command

php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Upvotes: 0

Ludovit Scholtz
Ludovit Scholtz

Reputation: 91

the file app/etc/env.php should start like this.. check your backend frontName :)

<?php
return array (
  'backend' => 
  array (
    'frontName' => 'admin_xu4zwa'
  ),
);

Upvotes: 6

Jaydeep Charadva
Jaydeep Charadva

Reputation: 147

I think you need to set web/unsecure/base_url and web/secure/base_url in core_config_data table with your url like : http://127.0.0.1/magento2/

Or you can set this setting from admin side Stores > Configuration > General > Web:
Base Urls

Base URL : http://127.0.0.1/magento2/

Base Urls (Secure)

Base URL : https://127.0.0.1/magento2/

Upvotes: 0

Sanaullah Ahmad
Sanaullah Ahmad

Reputation: 508

After installation of Magento2 site into a new location, you need to run all magento commands, after changing url in core_config_data table and changing connection in app/etc/env.php file.

php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Upvotes: 0

Mukesh Pandit
Mukesh Pandit

Reputation: 183

I think your magento installation foldername and value in table core_config_data field "base_url" is not same.

  1. In terminal run command: php bin/magento info:adminuri , say it shows: admin_mkp
  2. In database run sql: SELECT * FROM core_config_data WHERE (scope LIKE '%_url%' OR path LIKE '%_url%' OR value LIKE '%_url%') LIMIT 50
  3. Check value of web/unsecure/base_url say value is: http://127.0.0.1/magentoxyzfoldername/
  4. Now your adminurl should be like this: http://127.0.0.1/magentoxyzfoldername/admin_mkp

note: magentoxyzfoldername is your magento installation folder name.

Upvotes: 2

Manish Joy
Manish Joy

Reputation: 486

change base url from core_config_data table and check frontName in app/etc/env.php file. Hope, this will help.

Upvotes: 0

G tr
G tr

Reputation: 1

change the base_url value in table core_config_data to http://127.0.0.1/magento2/ instead of http://localhost/magento2/, you can find the record in the table using SELECT * FROM core_config_data WHERE path='web/unsecure/base_url';.

Upvotes: 0

Priyank
Priyank

Reputation: 1328

You need to check the following

  • Check Your admin backend name
  • make sure you have mod_rewrite enabled in apache
  • Make sure you have installed magento properly if not try to reinstall it.

Upvotes: 1

Vinoth kumar
Vinoth kumar

Reputation: 475

We can also check the admin url by using command

        $ php bin/magento info:adminuri

Upvotes: 1

Related Questions