views:

67

answers:

3

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

A: 

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

Tom Haigh
Thanks, it does but that is not exactly what i am trying to achieve - i want it to not show the url finishing in /index.php even if thats what you wrote...
Jamesaa
A: 

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.

Col. Shrapnel
Thanks, it does work as above all three versions would register the page, but i want whichever url you type to end up just as /directory/subdir_1 Sorry if it wasnt clear enough
Jamesaa
+1  A: 

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.

Jonathan Kuhn
As you say prob not the nicest way of doing it, i do have the urls not pointing to index.php, however all 3 potential versions of the url are ending up in my webmaster tools, and so i get the feeling having links to my site spread over those three versions could be compromising them.
Jamesaa
@Jamesaa there is nothing to compromise
Col. Shrapnel