Redirect admin login page

4 years ago
Hi,

I would like to redirect /admin to page not found instead of going to login page if user is not logged in. I have tried adding authentication in Administration/web.config but to no success. Is there any way i can achieve this?

Regards,
Chee Fi
4 years ago
Hello Cheefi,


Create your own route for admin panel.

So It's not required more customize for your requirement.

Let me know if you need any help from my side.

Thanks.
4 years ago
Hi nopSquare,

Even if i route admin to another url, when type the new url /(admin route) it will still opens up the login page. What I want is to route user to 404 instead of the login page for admin if user type /(admin route). Is there any way to do this?
4 years ago
Hello Cheefi,

Can you please share your code?

So we can try to resolved your issues.

Thanks,
4 years ago
Hello Cheefi,

Please try below code.


public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin1/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", area = "Admin", id = "" },
                new[] { "Nop.Admin.Controllers" }
            );
        }


Please try this code.

Let me know if your issue is resolved or not.

Thanks,
4 years ago
Hi,

This will change all my url to admin1/path. I still want to remain /admin. Its just that if user not logged in, when user type /admin, it will redirect to 404 not found page instead of /login. If user wants to login, they will login thru /login.