The file structure looks like this
- root
- root/x
- root/x/y.php
- root/index.php
.htaccess code
RewriteRule (.*) /x/$1 [L]
What the htaccess file does is to remove the folder name (x) from the url so accessing y.php = http://localhost/y.php instead of http://localhost/x/y.php . This works but my problem now is the index.php shows something like this:
Index of /x
Parent Directory
y.php
I can’t access the index.php. I believe the x became the root folder.
Thanks for your help!
First, you shouldn’t allow index displays like this on a public server … on your localhost it may be okay, but still, you can disable it in your .htaccess by adding this:
To address your question, you should probably add the following conditions before your rewrite rule so that the rule won’t apply to any files or directories that actually exist on disk:
This won’t fix the issue you have because the .htaccess is redirecting to a non-existant /x/index.php file … this is why it’s showing the index listing for the /x directory