htaccess, to catch all possible 404 requests, without ErrorDocument directive.
I've been trying to make a model/view structure for a website (or the aedrin's method ;)), so my root directory structure is
in my htaccess, which will convert all links like /about, /contact to ?page=about, ?page=contact and so on.
RewriteRule ^([^/\.]+)(/*)([^/\.]*)$ index.php?page=$1&rest=$3 [L]
And my index.php contains
The above code also works for /download/file1 to download a file named file1 (I've the required code in /model/download.php, $file=$_GET['rest']; .........)
if($page=="" || $page=="index.php")
Now, this setup works fine for all
/blah-blah type links, which will show a text in the
and thus I can
<p> Sorry, the requested page is not found in site. In case, if you have followed a valid link,
please <a href="
/contact_webmaster/page=blah-blah&rest=">let know the Majlis webmaster</a>.
catch the requested url in my contact_webmaster form.
Now my question are
- Can I catch requests (by modifying htaccess) like
/blah.blah etc.(currently showing an apache 404 error) in my index.php and pass through the rest of codes?
- How can I restrict request like /model/about.php,
/view/about.php etc. which is currently displaying a php error or some html with no styles
Hope my questions are clear.
After all sorry for this huge post and thank you for reading the same (I've no other way to explain) :)