的.htaccess,mod_rewrite的,而且基本身份验证身份验证、基本、htaccess、mod_rewrite

由网友(  舞↘唯Se彩巛)分享简介:我的工作就一个字preSS网站,我的网页使用的是固定链接结构mod_rewrites他们看起来像目录。几页我想使用基本身份验证密码保护的几个页面。我怎么会写在我的.htaccess文件?我在保护文件或重写地址?I am working on a Wordpress site, and my pages are usi...

我的工作就一个字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.

阅读全文

相关推荐

最新文章