当前位置:首页 » 编程语言 » php隐藏indexphp

php隐藏indexphp

发布时间: 2025-04-09 00:16:54

❶ 部分网站url中index.php自动隐藏是如何实现的

根目录下新建立一个配置文件,命名为: .htaccess
在里面这样写:

RewriteEngineon
RewriteCond$1!^(index.php|images|robots.txt)
RewriteRule^(.*)$/index.php/$1[L]

就可以去掉 index.php 了。要注意 /index.php/$1 要根据你目录(Web 目录,比如 http://www.domain.com/index.php)的实际情况来定,比如网站根目录是 /ci/index.php 则要写成 /ci/index.php/$1

RewriteCond$1!^(index.php|images|robots.txt)

上面的代码意思是排除某些目录或文件,使得这些目录不会 rewrite 到 index.php 上,这一般用在图片、js、css 等外部资源上。也就是说非 PHP 代码都要排除出去。(这里我排除了 images 目录和 robots.txt 文件,当然 index.php 也应该被排除)
哦,对了,还要修改 config.php 这个文件中的下列内容:

/*
|--------------------------------------------------------------------------
|IndexFile
|--------------------------------------------------------------------------
|
|Typicallythiswillbeyourindex.phpfile,unlessyou'verenameditto
|somethingelse.Ifyouareusingmod_rewritetoremovethepagesetthis
|variablesothatitisblank.
|
*/
$config['index_page']="index.php";

把其中的 "index.php" 改成 "" 就可以了。

热点内容
成都的dns服务器地址 发布:2025-04-29 23:57:49 浏览:764
咕咚数据不上传 发布:2025-04-29 23:52:46 浏览:121
存储芯片图 发布:2025-04-29 23:52:42 浏览:93
最强的服务器地址 发布:2025-04-29 23:51:11 浏览:150
中标麒麟外接存储设备 发布:2025-04-29 23:49:17 浏览:217
mfc文件夹重命名 发布:2025-04-29 23:49:10 浏览:160
python中文输出乱码 发布:2025-04-29 23:40:35 浏览:686
forifpython 发布:2025-04-29 23:18:24 浏览:524
删除python模块 发布:2025-04-29 23:14:27 浏览:751
锁定sim卡需要输入pin密码是多少 发布:2025-04-29 22:55:12 浏览:482