Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.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/6/apache/9.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_Apache_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

Php 如何禁止使用.htaccess访问子域?

Php 如何禁止使用.htaccess访问子域?,php,apache,.htaccess,redirect,mod-rewrite,Php,Apache,.htaccess,Redirect,Mod Rewrite,我正在使用一家网络托管公司,该公司认为为我的电子邮件设置提供网络访问将是一个“好主意”。所以基本上,如果我的网站是example.com,一个类似http://mailboxes.example.com将为此打开一个登录页面。所以我想知道是否有办法通过.htaccess禁用邮箱子域中的任何内容?(或者可以重定向它。) 到目前为止,我尝试了重定向: # Prevent webmail access RewriteCond %{HTTP_HOST} ^mailboxes\.example\.com$

我正在使用一家网络托管公司,该公司认为为我的电子邮件设置提供网络访问将是一个“好主意”。所以基本上,如果我的网站是
example.com
,一个类似
http://mailboxes.example.com
将为此打开一个登录页面。所以我想知道是否有办法通过
.htaccess
禁用
邮箱
子域中的任何内容?(或者可以重定向它。)

到目前为止,我尝试了重定向:

# Prevent webmail access
RewriteCond %{HTTP_HOST} ^mailboxes\.example\.com$   [NC]
RewriteRule ^ http://example.com/contactme  [L,R]
但这似乎没有任何作用,页面仍然会加载

编辑:伙计们,这里是完整的
.htaccess
文件,以防出现差异:

RewriteEngine on

# Define priority of which index file is used first
DirectoryIndex index.php index.htm index.html

# Error pages:
ErrorDocument 401 /err401.php
ErrorDocument 403 /err403.php
ErrorDocument 404 /err404.php
ErrorDocument 500 /err500.php

# Prevent opening directory listings from the web
Options -Indexes

# Prevent 'error_log' from being accessed from the web:
RewriteRule (^|/)error_log$ - [L,R=404]

# Redirect access to mailboxes subdomain
RewriteCond %{HTTP_HOST} ^mailboxes\.example\.com$   [NC]
RewriteRule ^ http://example.com/contactme/  [L,R]

# Prevent .ini and other files from being open from web browser
<filesMatch ".*\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
 Order Allow,Deny
 Deny from all
</filesMatch>

<filesMatch "phprc$">
 Order Allow,Deny
 Deny from all
</filesMatch>
重新编写引擎打开
#定义首先使用哪个索引文件的优先级
DirectoryIndex.php index.htm index.html
#错误页:
ErrorDocument 401/err401.php
ErrorDocument 403/err403.php
ErrorDocument 404/err404.php
ErrorDocument 500/err500.php
#阻止从web打开目录列表
选项-索引
#阻止从web访问“错误日志”:
重写规则(^ |/)错误日志$-[L,R=404]
#重定向对邮箱子域的访问
RewriteCond%{HTTP_HOST}^邮箱\.example\.com$[NC]
重写规则^http://example.com/contactme/  [左,右]
#阻止从web浏览器打开.ini和其他文件
命令允许,拒绝
全盘否定
命令允许,拒绝
全盘否定

这是因为您的
。htaccess
将永远不会执行。子域直接指向其他目录,因此您需要做的是在子域指向的位置创建一个
.htaccess
,并将其重定向到所需的域。哦,好的。这就解释了。所以我几乎被它卡住了。哈?不,如果您有域控制面板访问权限,那么您可以更改该子域的目录。contactme是否在第页?还是目录?@MohammedElhag:这是一个带有
索引的dir.php
,加载我的
联系我
页面。这是因为你的
而发生的。htaccess
将永远不会执行。子域直接指向其他目录,因此您需要做的是在子域指向的位置创建一个
.htaccess
,并将其重定向到所需的域。哦,好的。这就解释了。所以我几乎被它卡住了。哈?不,如果您有域控制面板访问权限,那么您可以更改该子域的目录。contactme是否在第页?还是目录?@MohammedElhag:这是一个带有
index.php
的目录,它加载了我的
联系我
页面。