Hello, this is my directory structure
/home
/template
/classifieds
/listings
I want to hide /template and want to show all files under template on home. like /home/template/home.php should be www.example.com/home.php or /home/template/style.css should be www.example.com/style.css
And Someone trying to access example.com/template/.php should be thrown back to example.com/.php if it exists or 404.php if it doesnt.
This was my htaccess to handle that.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} ^/template/.*php
RewriteRule . /$1 [NC,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Options -Indexes
And my php code
if (!file_exists("template/" . $page))
include_once "template/404.php";
else
include_once "template/" . $page;
However I have added more things like /classified and /listings should be listed as it is, i.e example.com/classified/*.php
Now when I try to access /answers/home.php it directly opens the home.php rather than opening index.php
This is my new code
if (!file_exists($segments[1] . '/' . $page))
include_once "template/404.php";
else
include_once $segments[1] . '/' . $page;
SO what should be the htaccess like ?