v5_6000 发表于 2010-8-27 02:35:20

分享index.php间接隐藏

本帖最后由 v5_6000 于 2010-8-27 02:37 编辑

看到论坛上很多讨论如何隐藏url中index.php的方法。
主要是方案是使用rewrite。

感觉rewrite方案是可行的,不过一个是效率一个是复杂度问题。

我采用了一个这种的方法。就是把index.php改个别的名字出现在url中也就不那么难看了。
比如 http://domain/index.php/blog/ 变成 http://domain/guest/blog/
1、将index.php重命名为guest
2、修改Apache配置文件,使用DefaultType指令
3、修改CI相关配置文件

该方案虽然不能减少url层数,但是隐藏了.php的扩展名,避免了一些复杂度。
不失为一种折中方案。

<Directory "/codeCenter/ci">
    DefaultType application/x-httpd-php
    DirectoryIndex guest index.html index.htm index.php index.shtml
</Directory>

Hex 发表于 2010-8-27 10:10:47

独辟蹊径,先不管好坏,总是很有新意的,呵呵

lamtin 发表于 2010-8-27 10:22:18

感觉这样还不如rewrite...

v5_6000 发表于 2010-8-27 13:20:25

感觉这样还不如rewrite...
lamtin 发表于 2010-8-27 10:22 http://codeigniter.org.cn/forums/images/common/back.gif


能说说不好的原因么?

lamtin 发表于 2010-8-27 16:46:49

回复 4# v5_6000


   用rewrite也就那么三句.

yanhuaguo 发表于 2010-9-3 17:36:14

独辟蹊径 至少想法是好的

Altair 发表于 2013-2-6 00:15:55

http://www.crazyfriday.net/2013/02/%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4url%E4%B8%ADindex-php%E7%9A%84%E7%BB%88%E6%9E%81%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/   如何删除URL中index.php的终极解决方案
页: [1]
查看完整版本: 分享index.php间接隐藏