I currently have these two pieces to my website.
localhost/FTS/papers
- which is a php filelocalhost/FTS/papers/
- which is a directory
What I am wanting to do is make it so that when I load:
localhost/FTS/papers
-or-localhost/FTS/papers/
-or-localhost/FTS/papers.php
I want them all to go to the papers file.
Right now it is accessing the directory instead of the file which is not what I want.
Place this rule in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteBase /FTS/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/FTS/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
I think it is rather confusing for PHP (as it also is for me) when you are talking to a papers directory or a papers document.
The best way, if possible, is to change the name of the papers document to papers_doc to ensure you that you are on the right place. (it's very error prone).
Than you can easily is the is_dir functionality of PHP to check if you are talking to a file or a directory:
var_dump(is_dir('a_file.txt'));
var_dump(is_dir('bogus_dir/abc'));
Or use is_file:
var_dump(is_file('a_file.txt'));
var_dump(is_file('bogus_dir/abc'));
One thing that you can do is place an htaccess file in the papers
directory with this rule:
RewriteEngine On
RewriteRule ^$ /FTS/papers.php [L]
And allow mod_dir to redirect /FTS/papers
to /FTS/papers/
.