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
Wordpress 一台服务器上的多个域和多个url重写规则htaccess_Wordpress_.htaccess_Url Rewriting_Multiple Domains - Fatal编程技术网

Wordpress 一台服务器上的多个域和多个url重写规则htaccess

Wordpress 一台服务器上的多个域和多个url重写规则htaccess,wordpress,.htaccess,url-rewriting,multiple-domains,Wordpress,.htaccess,Url Rewriting,Multiple Domains,我有两个wordpress站点位于同一个托管帐户上,它们各自位于自己的子目录中,并且有自己的数据库 -根 -地点1 -站点2 站点1有3个域名 地点1.dk site1.eu site1.org 站点2有1个域名 网站2.com 我想将site1.dk、site1.eu、site1.org指向子文件夹site1。和site2.com在子目录site2中 此外,我想删除子文件夹名称site1/2 我已在根目录中使用以下htaccess解决了site1 RewriteEngine On Rewrit

我有两个wordpress站点位于同一个托管帐户上,它们各自位于自己的子目录中,并且有自己的数据库

-根

-地点1

-站点2

站点1有3个域名 地点1.dk site1.eu site1.org

站点2有1个域名 网站2.com

我想将site1.dk、site1.eu、site1.org指向子文件夹site1。和site2.com在子目录site2中

此外,我想删除子文件夹名称site1/2

我已在根目录中使用以下htaccess解决了site1

RewriteEngine On
RewriteCond %{HTTP_HOST} ^site1\.dk$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site1 \.dk$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^site1\.eu$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site1\.eu$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^site1\.org$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site1\.org$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1/$1 [L,R=301]

RewriteRule ^$ site1/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ site1/$1 
上面所有的url都进入site1子文件夹,url看起来像这个site1.dk。好的,好的

但是如果我把它添加到根目录中

RewriteCond %{HTTP_HOST} ^site2\.org$ [NC]
RewriteRule ^site2/(.*)$ http://www.site2.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site2\.org$ [NC]
RewriteRule ^site2/(.*)$ http://www.site2.dk/site2/$1 [L,R=301]

RewriteRule ^$ site2/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ site2/$1 
一切都崩溃了

我不太熟悉htaccess和url重写,需要一些帮助

提前谢谢


//Kasper

我想您应该使用一个,而不是通过.htaccess来实现这一点。根据服务器的设置方式,您可能需要直接编辑apache/conf/extra/httpd-vhosts.conf,或者在cPanel/Plesk/WHM或类似文件中使用抽象层


在上面的示例中,根文件夹中不需要.htaccess文件。如果您的主机设置正确,则web访问者不应访问该主机。

不幸的是,服务器未设置虚拟主机,否则这是您提供的一个很好的解决方案!不能使用htaccess吗?