密码保护的CNAME子站点的.htaccess? [英] Password protect a cname subdomain with .htaccess?

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

问题描述

我试图建立和测试一个M。子域名网站我的工作。 m.domain.com简直是CNAME的domain.com,将被用于设置服务器端的布尔所以网站的移动版本将成为完全一样的页面,只需用不同的CSS和脚本。

I'm trying to build and test a "m." subdomain for a website I'm working on. "m.domain.com" is simply a cname for "domain.com" and will be used to set a server-side boolean so the mobile version of the site will serve exactly the same pages, just with different css and scripts.

虽然我测试,我想要求向m.domain.com发出的所有请求的密码。我试着在环境变量的解决方案的几个变种的.htaccess,这就是我现在所拥有的:

While I'm testing, I want to require a password for all requests made to m.domain.com. I've tried several .htaccess variants on environment variable solutions, and this is what I have right now:

SetEnvIfNoCase Host m\.domain\.com is_mobile

AuthType basic
AuthName "Mobile site"
AuthUserFile ".htpasswd"
Require valid-user

Order allow,deny
Allow from all
Deny from env=is_mobile
Satisfy any

通过这个code,domain.com和www.domain.com显示正常。如预期m.domain.com提示输入密码。但是,一旦它进入,在服务器上的任何请求返回500错误。

With this code, "domain.com" and "www.domain.com" display normally. "m.domain.com" prompts for a password as expected. However, once it's entered, the server returns a 500 error on any request.

推荐答案

嗯,事实证明了一点反转和重新排序并获得成功。

Well, turns out that a little inversion and reordering did the trick.

SetEnvIfNoCase Host ^(www\.)domain\.com$ not_mobile

AuthType basic
AuthName "Mobile site"
AuthUserFile ".htpasswd"

Order deny,allow
Deny from all
Allow from env=not_mobile
Require valid-user
Satisfy any

我还是想知道为什么其他配置创建的500错误,虽然,特别是因为它只是发生了,我想密码保护的子域。

I'm still curious to know why the other configuration created the 500 error, though, especially since it only occurred for the subdomain I wanted password protected.

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

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