Hello guys i am building up a project in php and facing issues regarding the wrong url my actual url is like this http://localhost/blog_dir/blog/top-of-the-world so when i am hitting to this url i can see the actual page that i want to see but when i am typing a wrong url like http://localhost/blog_dir/blog/top-of-the-w it shows me error like the notices, warnings and all the common errors of php into that page which is quite obvious as it is not getting the proper url. So what do i want to do is that if any user types wrong url then they must get redirected to the error page that i have created which is err.php. One more thing i would like to add is that the problem arises i think is due to the codes that i have written in my .htaccess. So i am adding up my .htacces code here
RewriteEngine On
ErrorDocument 404 http://localhost/blog_dir/err.php
#RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/([^/\.]+)?$ blog-de.php?post=$1 [L,QSA]
I hope you could help me out with my project....
This one can resolve your issue :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]
ErrorDocument 404 path_to_error_page
NB: replace path_to_error_page with the path to the error page.