I use a similar script that @megazoid supplied to test for files in a cache folder. If the file exists then it is activated otherwise the condition fails and falls through to the next test.
I think if you test the script it will be OK because .htaccess is called first.
You may have to amend the trailing [ L] parameter to quit parsing the reminder of the .htaccess file.
Tapped laboriously from a mobile and not able to test at the moment.
@keneso
This method may satisfy all your conditions:
I have a _CACHE-FOLDER that I test first to see if the cached file exists.
If it does then a .html version is activated otherwise the rule fails and falls through to /index.php
I loaded a subdirectory with its own index.php, then created a link in index.php in the root, clicked on the link, and it goes to the subdirectory, but shows the subdirectory name in browser address bar.
I tried .htaccess both in root, and in subdirectory.
I had understood that, but not the direct linking, how am I going to load the pages in subdirectory then?
Hiding the subdirectory is my goal, but seems from your explanation that’s not technically possible, so I guess I have to think over how to go about structuring the site.
I believe most CMS and PHP Frameworks entry point is always /index.php. This server file is then parsed and render a HTML, CSS and JavaScript file to a main/root menu.
All URLs first pass through the server index.php and then directed to an internal router where the relevant URL data is extracted and then sent to the CMS/PHP Framework “Engine”. An excellent Application Flow Chart can be seen here:
I think most CMS/PHP Frameworks supply an optional .htaccess file can hide /index.php. Configuration file parameters may be finely tuned to completely remove .php extensions or to add the old standard .html file extension. Modern trend is to have no file extensions. Pretty URLs may also be configured to eliminate potential security risks when using $_GET parameters.
Most CMS/PHP Frameworks have caching available which automatically stores the the rendered web page. As you can see from the diagram, the routed URL first tests for the existence of a cached file and if it exists the cached file is rendered without loading a any Drivers, Models, Libraries, Helpers, Packages or Scripts.
Edit:
Other advantages of using a single /index.php is that system updates are activated by setting the index.php->$system_path and if there if there are any problems then quickly revert back to the previous version. Online Development versions can run in tandem and eliminates ancient “Under Construction” pages.