Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Htaccess仅访问子域_Php_.htaccess_Dns_Cross Domain_Subdomain - Fatal编程技术网

Php Htaccess仅访问子域

Php Htaccess仅访问子域,php,.htaccess,dns,cross-domain,subdomain,Php,.htaccess,Dns,Cross Domain,Subdomain,我只想让人们查看我的子域,而不是原始域。我只想让我查看原始域(我指的是我的IP) 是否有任何脚本可用于htaccess? 谢谢在主域上创建一个htaccess文件,并在其中写入以下内容: Order deny, allow Deny from all Allow from 123.45.67.89 在上述代码中使用您的IP。您可以永久重定向到hello.example.com。这将确保每个人都在hello.example.com下访问您的站点。这将更适合您的用户 RewriteEngine

我只想让人们查看我的子域,而不是原始域。我只想让我查看原始域(我指的是我的IP)

是否有任何脚本可用于htaccess?
谢谢

在主域上创建一个htaccess文件,并在其中写入以下内容:

Order deny, allow
Deny from all
Allow from 123.45.67.89

在上述代码中使用您的IP。

您可以永久重定向到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] 

我找到了答案。我在位于example.com的htaccess中添加了此代码

order deny,allow
deny from all
allow from MYIP
并将此代码发送到hello.example.com

order deny,allow
allow from all

我不确定这样做是否正确,但它可以帮助我阻止人们查看example.com(主域),但仍然允许他们查看子域(hello.example.com)

如果我使用它,也会拒绝访问我的子域!我希望任何人都能查看子域,但我该如何查看example.com?它也将为我重定向。
order deny,allow
allow from all