1

如何限制使用 .htaccess 文件Deny from all但所有 $.post 请求、$.get 请求等的访问。我如何仍然从页面访问文件,但仅通过在浏览器中访问它来撤销直接访问?

4

1 回答 1

0

您可以通过 mod_rewrite 和类似条件使用 HTACCESS 禁用浏览器访问

RewriteCond %{HTTP_USER_AGENT} ^.*Firefox/4.*$
RewriteRule . - [R=404,L,NS]

ErrorDocument 404 /error.php?e=404

要访问该页面,您可以使用带有选项的 cURL,例如

curl_setopt($ch, CURLOPT_USERAGENT, "allowed_agent");
于 2012-07-26T20:07:16.523 回答