Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Apache 我可以从子域重写到文件夹以避免重定向吗?_Apache_Mod Rewrite_Subdomain - Fatal编程技术网

Apache 我可以从子域重写到文件夹以避免重定向吗?

Apache 我可以从子域重写到文件夹以避免重定向吗?,apache,mod-rewrite,subdomain,Apache,Mod Rewrite,Subdomain,我希望我的子域直接指向一个文件夹。 也就是说,如果向apple.example.com发出HTTP请求, 我希望响应是example.com/apple/index.html的内容,但不是301错误。 可能吗?是的,这正是像ISAPI\u REWRITE这样的工具的目的。我的托管公司(orcsweb)正是使用了这种技术 -是的,但是您需要确保您的服务器能够支持虚拟域。关于这一点我知道的不多,但是mod_重写可以不重定向。\35; internal rewrite.example.com/到exa

我希望我的子域直接指向一个文件夹。 也就是说,如果向apple.example.com发出HTTP请求, 我希望响应是example.com/apple/index.html的内容,但不是301错误。
可能吗?

是的,这正是像ISAPI\u REWRITE这样的工具的目的。我的托管公司(orcsweb)正是使用了这种技术


-是的,但是您需要确保您的服务器能够支持虚拟域。关于这一点我知道的不多,但是mod_重写可以不重定向。

\35; internal rewrite.example.com/到example.com/subs/您可以从任何文件夹提供内容,也可以向客户端发送重定向,但很好,你们不能同时做这两件事——你们不能同时提供内容和改变浏览器中的url

# Internally rewrite <subdomain>.example.com/<URLpath> to example.com/subs/<subdomain/<URLpath>
RewriteCond $1 !^subs/
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /subs/%1/$1 [L] 

如果可能的话,它肯定会导致许多安全漏洞。

我已经在网上找到了这个解决方案。但这对我不起作用。当我导航到apple.example.com时,浏览器中会显示以下错误----未找到请求的URL/未在此服务器上找到。