htaccess的不显示的index.php在子目录 [英] htaccess to not show index.php in sub directory

查看:243
本文介绍了htaccess的不显示的index.php在子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的页面结构如下图所示。

/directory/subdir_1/index.php

/directory/subdir_2/index.php

...

(有这些目录中没有其它文件)<​​/ P>

是有可能有假/ pretty的网址为上述文件如下?

/目录/ subdir_1

/目录/ subdir_2

...

所以这条道路将显示访问者是否输入了,/目录/ subdir_2 /或/directory/subdir_2/index.php。

感谢

解决方案

您可以检查 $ _ SERVER ['REQUEST_URI'] 在index.php文件顶部以获得地址,如果该字符串结尾的index.php重定向他们。不过,我建议不一定是这样做的,离开它。只要改变你的页面上的链接不包含的index.php。

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

解决方案

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.

这篇关于htaccess的不显示的index.php在子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆