Hi friends,
I've been trying to make a model/view structure for a website (or the
aedrin's method 
), so my root directory structure is
Code:
model/
view/
common/
classes/
css/
downloads/
images/
javascript/
index.php
.htaccess
I've
Code:
RewriteRule ^([^/\.]+)(/*)([^/\.]*)$ index.php?page=$1&rest=$3 [L]
in my htaccess, which will convert all links like
/about,
/contact to
?page=about,
?page=contact and so on.
And my index.php contains
PHP Code:
$page=trim($_GET['page']);
if($page=="" || $page=="index.php")
$page='home';
$general_pages=array("home","about","contact","contact_webmaster");
if(!in_array($page,$general_pages))
$page="404";
include("model/{$page}.php");
include("common/header.php");
include("common/nav.php");
@include("view/{$page}.php");
include("common/footer.php");
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']; .........)
Now, this setup works fine for all
/blah-blah type links, which will show a text in the
/view/404.php
Code:
<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>.
</p>
and thus I can
catch the requested url in my
contact_webmaster form.
Now my question are
- Can I catch requests (by modifying htaccess) like
/about.php, /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)
regards,
raoof.