2011-11-21 131 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将被重定向?

相关问题