欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Apache涓嬬姝hp鏂囦欢琚洿鎺ヨ闂殑鏂规硶_PHP鏁欑▼ | 甯涔嬪

程序员文章站 2022-04-28 17:42:40
...
銆€銆€涓€寮€濮嬶紝鎴戞兂鍦ㄩ噸鍐欒鍒欓噷鐩存帴绂佹php鍚庣紑鐨刄RL琚闂€備絾鍚庢潵鍙戠幇閲嶅啓瑙勫垯鏄€掑綊璋冪敤鐨勶紝濡傛灉鍦ㄩ噸鍐欒鍒欓噷鐩存帴绂佹php锛岄偅涔堥噸鍐欏埌php鏂囦欢鐨勮鍒欎篃浼氬け鏁堛€俁ewriteEngineOn

銆€銆€RewriteRule^test$/test.php[L]

銆€銆€RewriteRule^test.php$$0[F,L]

Apache涓嬬姝hp鏂囦欢琚洿鎺ヨ闂殑鏂规硶_PHP鏁欑▼ | 甯涔嬪

銆€銆€閫掑綊璋冪敤杩欑湡鍙€曪紝涓€寮€濮嬭闂?test鐨勬椂鍊橴RL閲嶅啓妫€鏌ヤ竴娆★紝鐒跺悗鍖归厤鍒癪test$灏卞唴閮ㄩ噸瀹氬悜鍒?test.php锛岀劧鑰屽唴閮ㄩ噸瀹氬悜涔熶細瑙﹀彂URL閲嶅啓锛屽洜姝ゅ啀娆℃鏌ワ紝鍖归厤鍒癪test.php$锛岃寮哄埗鐩存帴[F](Forbidden)鎿嶄綔锛屾墍浠ュ氨鍙樻垚浜?03閿欒銆傛棦鐒惰繖鏍凤紝灏卞繀椤诲垽鏄惁宸茬粡缁忚繃鏈嶅姟鍣ㄩ噸瀹氬悜銆傝繖鏃跺€欐湇鍔″櫒鍙橀噺閲屾湁涓猂EDIRECT_URL鍙互浣跨敤锛屽洜姝ゆ垜璇曠潃鐢ㄨ繖涓仛鍒ゆ柇銆?/p>

銆€銆€RewriteEngineOn

銆€銆€RewriteRule^test$/test.php[L]

銆€銆€RewriteCond%{REDIRECT_URL}^$

銆€銆€RewriteRule.*$0[F,L]杩欐牱鍐欒闂?test渚濇棫琚?03锛岀◢寰鏌ヤ笅锛屽彂鐜癛ewriteCond涓?{REDIRECT_URL}姘歌繙涓虹┖锛岃繖灏辫泲鐤间簡锛岃繖鏍风殑璇濆湪閲嶅啓瑙勫垯涓病鍔炴硶鐩存帴绂佹php浜嗐€備絾鏄彲浠ョ敤涓嶆€庝箞鍗庝附鐨勬柟娉曞疄鐜般€傚氨鏄湪php鏂囦欢涓幓鍒ゆ柇REDIRECT_URL锛岃櫧鐒惰繖涓柟娉曞彲浠ュ疄鐜帮紝浣嗘槸鎰熻寰堥€婏紝鍙槸鐩墠涓烘涔熸病鎵惧埌浠€涔堟洿濂界殑鍔炴硶浜嗐€?/p>

銆€銆€$_SERVER['REDIRECT_URL']ordie('Forbidden');

銆€銆€//杩欓噷鍙槸鏄剧ず鏂囧瓧鑰屽凡锛屽疄闄呬娇鐢ㄧ殑鏃跺€欒繕闇€杈撳嚭鐨凥TTP閿欒浠g爜銆?/p>

銆€銆€echo$_SERVER['REDIRECT_URL'];//鎴愬姛璁块棶鏄剧ず淇℃伅

銆€銆€?>

Apache涓嬬姝hp鏂囦欢琚洿鎺ヨ闂殑鏂规硶_PHP鏁欑▼ | 甯涔嬪

銆€銆€鎶婅繖娈礟HP浠g爜淇敼涓嬩涪杩涘叏灞€寮曠敤閲屽氨鍩烘湰涓婃病鍟ラ棶棰樹簡锛岃櫧鐒朵笉鏄畬缇庤В鍐筹紝浣嗘槸鑷冲皯杩樻槸瑙e喅浜嗭紝浠ュ悗涔熻浼氬彂鐜版洿濂界殑鏂规硶銆?/p>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/371929.htmlTechArticle涓€寮€濮嬶紝鎴戞兂鍦ㄩ噸鍐欒鍒欓噷鐩存帴绂佹php鍚庣紑鐨刄RL琚闂€備絾鍚庢潵鍙戠幇閲嶅啓瑙勫垯鏄€掑綊璋冪敤鐨勶紝濡傛灉鍦ㄩ噸鍐欒鍒欓噷鐩存帴绂佹php锛岄偅涔堥噸鍐欏埌...