Apache涓嬬姝hp鏂囦欢琚洿鎺ヨ闂殑鏂规硶_PHP鏁欑▼ | 甯涔嬪
銆€銆€RewriteRule^test$/test.php[L]
銆€銆€RewriteRule^test.php$$0[F,L]
銆€銆€閫掑綊璋冪敤杩欑湡鍙€曪紝涓€寮€濮嬭闂?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'];//鎴愬姛璁块棶鏄剧ず淇℃伅
銆€銆€?>
銆€銆€鎶婅繖娈礟HP浠g爜淇敼涓嬩涪杩涘叏灞€寮曠敤閲屽氨鍩烘湰涓婃病鍟ラ棶棰樹簡锛岃櫧鐒朵笉鏄畬缇庤В鍐筹紝浣嗘槸鑷冲皯杩樻槸瑙e喅浜嗭紝浠ュ悗涔熻浼氬彂鐜版洿濂界殑鏂规硶銆?/p>