当前位置:首页 » 编程语言 » 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" 改成 "" 就可以了。

热点内容
scratch少儿编程课程 发布:2025-04-16 17:11:44 浏览:619
荣耀x10从哪里设置密码 发布:2025-04-16 17:11:43 浏览:346
java从入门到精通视频 发布:2025-04-16 17:11:43 浏览:62
php微信接口教程 发布:2025-04-16 17:07:30 浏览:288
android实现阴影 发布:2025-04-16 16:50:08 浏览:781
粉笔直播课缓存 发布:2025-04-16 16:31:21 浏览:333
机顶盒都有什么配置 发布:2025-04-16 16:24:37 浏览:196
编写手游反编译都需要学习什么 发布:2025-04-16 16:19:36 浏览:785
proteus编译文件位置 发布:2025-04-16 16:18:44 浏览:349
土压缩的本质 发布:2025-04-16 16:13:21 浏览:578