There is an issue with redirection to error pages:
example.com/test
- will redirect to 404 error page
but
example.com/test/
- will go to the white "File not found." page
to mention:
- it was working properly until some time ago (maybe update of PHP version ??)
- same behavior with www/http/https version of the links
- standard structure of the links is
www.example.com/test/
.htaccess file code
<Files .htaccess>
order allow,deny
deny from all
</Files>
RewriteEngine On
RewriteRule ^([^/] )/$ $1.php
RewriteRule ^([^/] )/([^/] )/$ /$1/$2.php
RewriteRule sample/(.*)/(.*)/$ /sample.php?$1=$2
ErrorDocument 400 /400.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 410 /410.php
CodePudding user response:
The problem is with ending slash of RewriteRule ^([^/] )/$ $1.php
If you write RewriteRule ^([^/] )/?$ $1.php
the tailing slash would be optional.
edit
You should also add
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
before RewriteRule
statements, because of server loop - when the file exists the statements will break loop by skipping rewriting.
CodePudding user response:
I would suggest that you try adding a /
as follows:
RewriteRule ^([^/] )/$ /$1.php
#----------------------^