0

我需要使用 htaccess 保护 Joomla CMS 中的“单一逻辑”url。我在这里找到.htaccess 代码来保护单个 URL?

此解决方案适用于特定的 url:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/index\.php$
RewriteCond %{QUERY_STRING} ^option=com_content&task=view&id=76$
RewriteRule ^(.*)$ /secure.htm

但是,如何确保 url 部分不能被交换或修改,从而绕过安全访问。例如我不想允许访问

option=com_content&task=view&id=76&dummy=1 
option=com_content&id=76&task=view

任何一个。

我试过这个,这似乎不起作用:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/index\.php$
RewriteCond %{QUERY_STRING} option=com_content
RewriteCond %{QUERY_STRING} task=view
RewriteCond %{QUERY_STRING} id=76
RewriteRule ^(.*)$ /secure.htm
4

1 回答 1

0

当我访问以下任何 URL 时,您的规则对我很有效:

  • http://localhost/index.php?blah=blah&option=com_content&task=view&id=76
  • http://localhost/index.php?option=com_content&task=view&id=76&dummy=1
  • http://localhost/index.php?option=com_content&id=76&task=view

我收到的内容是/secure.htm

但是,您可以向查询字符串规则添加声音边界:

RewriteCond %{QUERY_STRING} (^|&)option=com_content(&|$)
RewriteCond %{QUERY_STRING} (^|&)task=view(&|$)
RewriteCond %{QUERY_STRING} (^|&)id=76(&|$)

这样你就不会匹配到类似的东西id=761

于 2012-09-20T15:15:46.827 回答