的.htaccess,mod_rewrite的,而且基本身份验证 [英] .htaccess, mod_rewrite, and basic authentication

查看:231
本文介绍了的.htaccess,mod_rewrite的,而且基本身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作就一个字preSS网站,我的网页使用的是固定链接结构mod_rewrites他们看起来像目录。几页我想使用基本身份验证密码保护的几个页面。我怎么会写在我的.htaccess文件?我在保护文件或重写地址?

I am working on a Wordpress site, and my pages are using a permalink structure that mod_rewrites them to look like directories. For a few pages I want to use Basic Authentication to password protect a few of the pages. How would I write this in my .htaccess file? Am I protecting the file, or the rewritten address?

推荐答案

您不会需要mod_rewrite的对于这一点,我们希望,这应该做的伎俩:

You won't need mod_rewrite for this, hopefully, this should do the trick:

SetEnvIfNoCase Request_URI ^/some/path/to/protect require_auth=true
SetEnvIfNoCase Request_URI ^/another/protected/path require_auth=true

# Auth stuff
AuthUserFile /var/www/htpasswd
AuthName "Password Protected"
AuthType Basic

# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth

本的mod_auth和mod_env模块的的有precidence了mod_rewrite的,所以你的假目录结构应保持不变。你只需要填写一份 SetEnvIfNoCase REQUEST_URI ^ /一些/路径/要/保护require_auth = TRUE 为每一个,再填写的AUTH东西休息满足您的需求。

The mod_auth and mod_env modules should have precidence over mod_rewrite, so your fake directory structure should stay the same. You'd just need to fill out a SetEnvIfNoCase Request_URI ^/some/path/to/protect require_auth=true for each one, then fill out the rest of the auth stuff to suit your needs.

这篇关于的.htaccess,mod_rewrite的,而且基本身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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