开发者

htaccess to not show index.php in sub directory

I have a simple page structure like below

/directory/subdir_1/index.p开发者_JAVA百科hp

/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


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜