Reputation: 11
I have a simple page structure like below
/directory/subdir_1/index.php
/directory/subdir_2/index.php
....
(there are no other files in these directories)
is it possible to have 'fake/pretty' urls for the above files as below?
/directory/subdir_1
/directory/subdir_2
...
so this path would show whether the visitor typed that,/directory/subdir_2/ or /directory/subdir_2/index.php.
Many thanks
Upvotes: 1
Views: 936
Reputation: 15301
You could check $_SERVER['REQUEST_URI']
at the top of index.php to get the address and if the string ends with index.php redirect them. However, I would suggest not necessarily doing this and leaving it. Just change the links on your page to not include index.php.
Upvotes: 1
Reputation: 157887
Question is too unclear to me.
but by default web-server works as you described:
Both /directory/subdir_2/
or /directory/subdir_2/index.php
would run index.php from the /directory/subdir_2/
.
If you want to redirect a client in case it requests /directory/subdir_2/index.php
, to the /directory/subdir_2/
you'd better not to do it. Just have all links on your site without trailing index.php.
Upvotes: 0
Reputation: 57815
If you have
DirectoryIndex index.php
in your .conf or .htaccess file, it should do that anyway. see http://httpd.apache.org/docs/2.2/mod/mod_dir.html#DirectoryIndex
Upvotes: 0