【问题标题】:dont allow user access joomla catalog using .htaccess不允许用户使用 .htaccess 访问 joomla 目录
【发布时间】:2014-01-03 11:16:31
【问题描述】:

我有一个带有文章网址的 joomla 网站,例如:http://domain.com/catalog/article.html

网络允许用户访问url:http://domain.com/catalog/article.html

但不允许使用 url:http://domain.com/catalog/ 或 http://domain.com/catalog.html

我尝试使用 htaccess 但它不起作用

RewriteCond %{REQUEST_URI}  =http:// domain .com/catalog/ 
RewriteRule /catalog/ http:// domain .com/

谢谢

注意: 因为目录有大约 200.000 篇文章。当用户列出此目录的文章时服务器已关闭,例如请求 url:http://domain.com/catalog/

有没有这样的:

If (url==http:// domain .com/catalog/){
   #redirect homepage
}else {
   #do nothing, allow users access the url
}  

【问题讨论】:

  • 你到底想做什么?你能提供一些例子吗?
  • 我尝试允许用户访问目录中的文章但拒绝目录中的文章
  • 那么您要屏蔽哪个网址?你想阻止http://domain.com/catalog/ URL吗?
  • 是的。 http:// domain .com/catalog, http:// domain .com/catalog/, http:// domain .com/catalog.html 必须被屏蔽或重定向到主页
  • 好的,在下面提供了答案。

标签: regex apache .htaccess mod-rewrite joomla


【解决方案1】:

将此代码放入您的DOCUMENT_ROOT/.htaccess 文件中:

RewriteEngine On

RewriteRule ^catalog(\.html|/)?$ - [NC,F]

【讨论】:

  • 除非/catalog/ 目录中有 .htaccess,否则此规则不会阻止 /catalog/。还要确保这是您的第一条规则,并在新浏览器中进行测试以避免以前的缓存。
【解决方案2】:

试试

RewriteEngine On
RewriteRule ^catalog(/|\.html)$ error_page.php [L]

【讨论】:

    猜你喜欢
    • 2016-05-02
    • 2019-03-03
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 2012-09-20
    • 2011-09-26
    • 2013-10-18
    • 2015-08-07
    相关资源
    最近更新 更多