當前位置:首頁 » 編程語言 » 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" 改成 "" 就可以了。

熱點內容
年輕人運行內存為什麼比安卓好 發布:2025-07-15 08:52:03 瀏覽:512
怎麼配置組策略 發布:2025-07-15 08:52:02 瀏覽:244
pythonjson格式 發布:2025-07-15 08:42:54 瀏覽:675
醫院葯房要什麼配置 發布:2025-07-15 08:29:55 瀏覽:663
編程說明書 發布:2025-07-15 08:16:39 瀏覽:759
android請求超時 發布:2025-07-15 07:56:57 瀏覽:528
修改linux的主機名 發布:2025-07-15 07:52:46 瀏覽:905
天龍八部自動挖礦腳本怎麼寫 發布:2025-07-15 07:42:01 瀏覽:648
本地編譯器怎麼運行 發布:2025-07-15 07:42:00 瀏覽:995
加密狗會壞嗎 發布:2025-07-15 07:38:32 瀏覽:563