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 ?
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.
Inside /admin/.htaccess
you can have this line:
DirectoryIndex login.php
This will load login.php
if /admin/
is requested.
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
You can use only one RewriteRule
with:
RewriteRule ^admin/?$ admin/login.php [NC,L]
Works with admin
or admin/
or AdMin
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.