0

I have this code in my HTACCESS

ErrorDocument 404 /errors-404.html
ErrorDocument 403 /errors-404.html

RewriteEngine On
RewriteBase /admin/
DirectoryIndex /auth/login.php
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.php - [F,L]
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^([a-zA-Z0-9]+)(/)?$ $1.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

I want visitor to redirect to my custom 404 page when they visit www.site.com/login.php it must be www.site.com/login to get to login page but the problem in my HTACCESS is my DirectoryIndex when they open my site they redirect to my 404 page

  • What do you mean by "the problem in my HTACCESS is my DirectoryIndex when they open my site they redirect to my 404 page"? If the `DirectoryIndex` is an issue, then deactivate it. And what does that have to do with an error page? – arkascha Jul 29 '19 at 17:13
  • Apart from that: why would you want to respond with an error_ to a request to the login endpoint? Why not simply _redirect_ it to the correct endpoint? – arkascha Jul 29 '19 at 17:14
  • @arkascha i want to disable visiting with .php or with .html if they do they will redirect to 404 because it was disable – Ellsowrth Sanders Jul 30 '19 at 12:33
  • Which is not an answer to my question but just a repetition of what you already wrote, correct? Why don't you answer the question instead? – arkascha Jul 30 '19 at 16:08
  • Guess this is some sort of “interference”, DirectoryIndex must cause the internal request URI to change, and then the RewriteRule pattern `^(.+)\.php` matches on that. `RewriteCond %{ENV:REDIRECT_STATUS} ^$` was probably meant to prevent that from happening - but the comments on https://stackoverflow.com/a/20930010/10283047 suggest that mod_dir directives might change this value as well, and therefor you might need to check it against `200` as well. – misorude Aug 01 '19 at 11:19

0 Answers0