Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 htaccess-为附加域重写/重定向?_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache htaccess-为附加域重写/重定向?

Apache htaccess-为附加域重写/重定向?,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我计划通过cPanel创建一些附加域,我知道他们的内容可以通过访问addondomain.maindomain.com和maindomain.com/addondomain来访问-这可能会导致搜索引擎重复内容,因此我希望尽可能避免这种情况 经过一些研究,这似乎是最好的(可能只是最好的)选项是使用.htaccess并重写,以便只能在www.addondomain.com上访问加载项域-执行此操作的最佳方式是什么?我是否可以在maindomain.com目录中拥有.htaccess文件,或者我创建的

我计划通过cPanel创建一些附加域,我知道他们的内容可以通过访问
addondomain.maindomain.com
maindomain.com/addondomain
来访问-这可能会导致搜索引擎重复内容,因此我希望尽可能避免这种情况

经过一些研究,这似乎是最好的(可能只是最好的)选项是使用.htaccess并重写,以便只能在www.addondomain.com上访问加载项域-执行此操作的最佳方式是什么?我是否可以在
maindomain.com
目录中拥有.htaccess文件,或者我创建的每个加载项域都需要它

任何帮助都将不胜感激,谢谢:)

此代码将用户从
maindomain.com/addonedomain
目录重定向到
addonedomain.maindomain.com

最好将此代码放在附加域根目录下的
.htaccess
文件中

我希望有一天,当控制面板的创造者了解一些关于网站。。。文件应该放在主域的根目录中。否则,此
重写规则将不匹配。
RewriteRule ^addonedomain/(.*)$ http://addondomain.maindomain.com/$1