[英]how to set htaccess to only allow www and dev
I have a server and I'm trying to setup a dev and production environment but when the production server is live is allowing any random subdomain on the request url like:我有一台服务器,我正在尝试设置开发和生产环境,但是当生产服务器处于活动状态时,允许请求 url 上的任何随机子域,例如:
abc.example.com
and I wanna to allow only www and dev, this is my .htaccess settings:我只想允许 www 和 dev,这是我的 .htaccess 设置:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^dev\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.example.com%{REQUEST_URI} [R=301,L]
Is there a way to achieve that and is my htaccess ok?有没有办法实现这一点,我的 htaccess 可以吗?
This might work:这可能有效:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^dev\. [NC]
RewriteRule ^ %{REQUEST_SCHEME}://www.example.com%{REQUEST_URI} [R=301,L]
apache variable %{REQUEST_SCHEME} passes http or https according to your request. apache 变量 %{REQUEST_SCHEME} 根据您的要求传递 http 或 https。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.