2012-09-20 33 views
0

我需要使用htaccess保护Joomla CMS中的“单一逻辑”网址。我发现这里.htaccess code to protect a single URL?.htaccess使用查询字符串组合保护网址

该解决方案,这对于一个特定的URL的伟大工程:

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

但是,我怎么能确保该网址的部分不能被交换周围或修订,因此绕过安全访问。例如我不想允许访问

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 

回答

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

匹配的东西
相关问题