1

hello I have a website that includes an /admin folder in this folder I have a login.php file

How can I make it redirect the website.com/admin to website.com/admin/login.php using .htaccess inside the /admin folder ?

4 Answers 4

1

Inside /admin/.htaccess you can have this line:

DirectoryIndex login.php

This will load login.php if /admin/ is requested.

Sign up to request clarification or add additional context in comments.

Comments

1

OK, this is even simpler and can be done like this:

RewriteCond %{REQUEST_URI} ^/admin$
RewriteRule .* http://yourhostname.tld/admin/login.php [L]

Just adjust the domain name to your needs.

1 Comment

RewriteRule .* /admin/login.php [L]
0

Try this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* login.php [L]

This will redirect all request to login.php if 1) requested resource is not an existing file 2) requested resource is not an existing directory 3) requested resource is not an existing link 4) This will be the last redirect rule used

1 Comment

I am afraid this is not what I asked for ! I want to specifically let the user when he launches website.com/admin to be directly directed to website.com/admin/login.php nothing more
0

You can use only one RewriteRule with:

RewriteRule ^admin/?$ admin/login.php [NC,L]

Works with admin or admin/ or AdMin...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.