对于单个的.htaccess重写密码保护 [英] Password protection for a single .htaccess rewrite

查看:113
本文介绍了对于单个的.htaccess重写密码保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个网站的密码保护。这是一个搜索引擎友好的网址: 默认的路径是:

I need a password protection for a single site. This is a seo friendly url: The default path is:

http://www.website-url.com/index.php?id_cms=xx&controller=cms

和这里是SEO网址:

http://www.website-url.com/content/xx-login

我已经在htaccess的和。htpasswd的,但如何指定在.htaccess仅此URL重写?我想这样的:

I have already the .htaccess and .htpasswd, but how to specify rewriting in .htaccess only for this url? I tried this:

<filesMatch "http://www.website-url.com/content/xx-login">
IndexIgnore .htaccess .htpasswd
AuthUserFile /absolut_path/.htpasswd
AuthName "Login"
AuthType Basic
require valid-user
</filesMatch>

我用prestashop。

I'm using Prestashop.

推荐答案

FilesMatch不会按照这种方式,你可以尝试使用SetEnvIf之后绕过验证,除非该URI是具体的(东西是我收集你想做):

FilesMatch doesn't work that way, you could try using SetEnvIf to bypass the Auth unless the URI is something specific (which is what I gather you are trying to do):

IndexIgnore .htaccess .htpasswd

SetEnvIfNoCase Request_URI "^/content/xx-login" SECURED

# enforce auth if SECURED
AuthType Basic
AuthName "Login"
AuthUserFile /absolut_path/.htpasswd
Require valid-user
Order allow,deny
Allow from env=!SECURED
Satisfy any

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

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