2013-01-07 43 views
0

我想只让人们查看我的子域名不是原始域名。我只想让我看到原始域(我的意思是我的IP)。Htaccess只能访问子域名

hello.example.com -> view by anyone 
example.com -> only view by me 

是否有我可以用于htaccess的任何脚本? 感谢

回答

1

你的主域名创建一个htaccess文件,写在它的下面:

Order deny, allow 
Deny from all 
Allow from 123.45.67.89 

用你的IP在上面的代码。

+0

如果我使用它,它也会拒绝访问我的子域名!我希望任何人都能查看子域名 – user1725155

0

您可以对hello.example.com进行永久重定向。这将确保每个人在hello.example.com下访问您的网站。这对你的用户更合适。

RewriteEngine On 

RewriteCond %{HTTP_HOST} ^example.com [nc] 
RewriteRule ^hello/(.*)$ http://hello.example.com/$1 [r=301,nc] 

如果你真的想显示403禁止,你可以做到这一点

RewriteEngine On 

RewriteCond %{HTTP_HOST} ^example.com [nc] 
RewriteRule ^hello/(.*)$/[r=403,nc] 
+0

,但我想如何查看example.com?它也将被重定向到我。 – user1725155

0

我想出答案。我加入htaccess的这个代码位于example.com

order deny,allow 
deny from all 
allow from MYIP 

与此代码hello.example.com

order deny,allow 
allow from all 

我不知道,如果是做一个适当的方式这有助于我阻止人们查看example.com(主域名),但仍然让他们查看子域名(hello.example.com)