2011-11-21 126 views
0

可以.htaccess重定向用戶而不更改它們鍵入的url嗎?htaccess重定向頁面而不更改網址

http://example.com/sample1.php 
http://example.com/sample2.php#anchor 
http://example.com/sample3.php?a=1#anchor 
# All 3 files open the file main.php but the URL remains the same 
+0

你使用的是Apache並且有mod_rewrite? –

回答

0

我找到了一個答案,但我對它的安全含義持謹慎態度。是把這個代碼在.htaccess一個可能的安全漏洞:

RewriteCond %{REQUEST_URI} ^/sample1.php [OR] 
RewriteCond %{REQUEST_URI} ^/sample2.php 
RewriteRule ^.* /main.php [L] 

這是否構成威脅還是確定,因爲我明確地記下了,只有sample1.php和sample2.php將被重定向?

相關問題