1

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

Jamesaa
  • 11
  • 2

3 Answers3

1

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
  • 15,279
  • 3
  • 32
  • 43
  • 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 May 20 '10 at 11:35
  • @Jamesaa there is nothing to compromise – Your Common Sense May 20 '10 at 11:44
0

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
  • 57,217
  • 21
  • 114
  • 142
  • 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 May 20 '10 at 11:22
0

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.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • 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 May 20 '10 at 11:20