Reputation: 952
lets say I have directory regions in my root:
root/regions
I want to load index.php file which is located in regions folder if user visits one of the following:
http://www.example.com/regions/united-kingdom
http://www.example.com/regions/united-kingdom/london
http://www.example.com/regions/united-kingdom/londom/rm8-16de
Country, city and post code dont exist as directory ! How to do that? Thank you in advance!
Upvotes: 1
Views: 92
Reputation: 785196
In your regions/.htaccess
you can have this .htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /regions/
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Upvotes: 1
Reputation: 21681
The order should be DirectoryIndex index.html index.php // default is index.html.
If the webserver finds no files in the current directory that matches names in the DirectoryIndex directive, then a directory listing will be displayed to the browser, showing all files in the current directory. Apache will look for each of the above files, in order, and serve the first one it finds when a visitor requests just a directory.
Once check DirectoryIndex which is solution for you.
Let me know if you face any query/concern regarding this.
Thanks!
Upvotes: 0