Hi,
I have been trying to overcome a problem with directories that were auto generated without having to move files around extensively using mod_rewrite. Basically I have say a directory named:
blah
And also a file named:
blah.php
Ideally blah.php should be index.php within the directory blah but for whatever reason in the process this didn't happen.
I came up with this:
RewriteCond %{SCRIPT_FILENAME}/index.php !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
The idea is if I type in a directory path and index.php does not exist then pull up the file with the same name as the directory with the .php extension.
It works in the most basic sense. If I enter the URL of a directory without a forward slash at the end I get what I want.
The only problem I run into is if I add in a / at the end. Then it fails to pull it up. I believe it is failing because blah/.php does not exist but despite searching around a can't find any method for trimming the / off of the path before adding in the php extension. It may not even be possible and if it's not I will just have to find another way but I figured it may be possible and I'm hoping someone may have an idea that may at least put me in the right direction.
Thanks for the help
Stewart