2013-01-07 58 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)