.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 :(得分:0)
我找到了答案,但我对其安全隐患持谨慎态度。将此代码放在.htaccess中是一个可能的安全漏洞:
RewriteCond %{REQUEST_URI} ^/sample1.php [OR]
RewriteCond %{REQUEST_URI} ^/sample2.php
RewriteRule ^.* /main.php [L]
这是否构成威胁还是没关系,因为我明确写下只会重定向sample1.php和sample2.php?