How to redirect on **404.php** when bad URL is found? [closed]

三世轮回 提交于 2020-03-04 18:31:37

问题


I have that in my .htaccess.

ErrorDocument 404 https://my_site.com/404.php
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ view_page.php?id_page=$1 [QSA,L]

When I enter that URL: https://my_site.com/this_file_not_exist.php

I'm redirected on: 404.php

But when I enter that URL: https://my_site.com/that_folder_not_exist/bad_folder/..../this_file_not_exist.php

Instead of being redirected on: 404.php

Chrome show this error: ERR_TOO_MANY_REDIRECTS

How to redirect on 404.php when bad URL is found ?

How to also redirect on 404.php when folder is not https://my_site.com/login/ or not https://my_site.com/ ?

Thanks.

来源:https://stackoverflow.com/questions/60463906/how-to-redirect-on-404-php-when-bad-url-is-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!