试图密码保护与htaccess的网址 [英] Trying to password protect a URL with htaccess

查看:135
本文介绍了试图密码保护与htaccess的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用防爆pression引擎2自由职业者的Editon不具有认证模块。

I am using Expression Engine 2 Freelancer editon that doesn't have an authentication module.

我想密码保护,有一个虚拟目录中的模板组的 www.domain.com/template

I am trying to password protect a template group that has a virtual directory www.domain.com/template

我所要做的是使用htaccess的根迫人,当他们尝试并导航到为模板部分,这两个文件在其下输入用户名和密码。

What I am trying to do is use the htaccess in the root to force people to enter a username and password when they try and navigate to the to "template" section and the two files under it.

这前pression发动机的工作模板发送到,而不是物理目录的方式。

The way that Expression Engine works the templates are routed to and not physical directories.

我的问题是我怎么能密码保护这个网址,我试图用LocationMatch,但没有奏效?

My question is how can I password protect this url, I tried using LocationMatch but it didn't work?

感谢

推荐答案

哪种去除方法的index.php 从URL您使用?

Which method of removing index.php from the URL are you using?

如果您使用的是文件和目录检查 方法,你可以修改的Apache 的mod_rewrite 规则,排除某个目录,同时允许所有其他请求被通的index.php

If you're using the "File and Directory Check" Method, you can modify the stock Apache mod_rewrite rule to exclude a certain directory while still allowing all other requests to be run thru index.php.

例如,使用基地文件和目录检查重写规则:

For example, using the base "File and Directory Check" rewrite rule:

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule>

通过这种方法,阿帕奇检查,看是否存在文件或目录 - 如果它确实该文件提供给浏览器;如果它不存在,然后将其发送直通的index.php 和解析为的防爆pressionEngine URI

With this method, Apache checks to see if the file or directory exists -- if it does the file is served to the browser; if it doesn't exist then it's sent thru index.php and parsed as an ExpressionEngine URI.

要排除的目录中,加入你的.htaccess基本身份验证密码保护的目录

To exclude your directory, modify the rewrite rule by adding your .htaccess Basic Authenticated password-protected directory:

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteCond %{REQUEST_URI} !^/(secret-directory|secret-directory/.*)$
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule>

我不完全知道什么所有的限制都与自由职业者许可的,但我answered关于防爆pressionEngine 密码保护网页,可能被证明有助于您的情况类似的问题。

I'm not fully aware of what all the limitations are with the Freelancer License, but I answered a similar question about password-protecting pages in ExpressionEnginethat may prove helpful in your situation.

这篇关于试图密码保护与htaccess的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆