共享主机,多个站点,由于.htAccess重定向而无法登录WP

时间:2012-06-04 作者:javy

我有一个共享的托管帐户,上面有3个独立的域。每个站点都在自己的目录中,所以请通过。htaccess将每个域名重写到相应的文件夹中。

当我尝试登录到WP时,地址栏中显示的重定向URL中包含域的文件夹。

例如:www.domain1。com位于文件夹/域1下

登录后的登录重定向为http://www.domain1.com/wp-login.php?redirect_to=http%3A%2F%2Fwww.domain1.com%2Fdomain1%2Fwp-admin%2F&reauth=1

所以它只是把我带回登录屏幕,没有错误消息或任何东西。。。但是,如果我重置密码,我可以成功登录。但在注销时,我再次进入重定向循环。

编辑-此代码位于。htaccess位于/public_html/. 还有一个。htaccess内部/public_html/domain1/ 使用标准Wordpress行。

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(.*)domain1.com$ [NC]
RewriteRule ^(.*)$ /domain1/$1 [L]

RewriteCond %{HTTP_HOST} ^(.*)domain2.com$ [NC]
RewriteRule ^(.*)$ /domain2/$1 [L]

RewriteCond %{HTTP_HOST} ^(.*)domain3.com$ [NC]
RewriteRule ^(.*)$ /domain3/$1 [L]

1 个回复
最合适的回答,由SO网友:javy 整理而成

@define(\'ADMIN_COOKIE_PATH\', \'/\');

把这个放在wp-config.php 允许我登录。不确定这是否是设置所有内容的正确方法,但它确实有效。。。

EDIT

这只解决了一半的问题。Permalinks随后被打破。

@托肖向任何可能看到这一点并有类似问题的人提出了适当的建议。

然而,这个托管提供商不允许虚拟主机,所以如果你处于类似的情况下,最终对我有用的是更多。htaccess线路(见下文)与wp-config 上述修改。

# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.

RewriteEngine on

# Change example.com to be your main domain.

RewriteCond %{HTTP_HOST} ^(www.)?example.com$

# Change \'subdirectory\' to be the directory you will use for your main domain.

RewriteCond %{REQUEST_URI} !^/subdirectory/

# Don\'t change these line.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change \'subdirectory\' to be the directory you will use for your main domain.

RewriteRule ^(.*)$ /subdirectory/$1

# Change example.com to be your main domain again.
# Change \'subdirectory\' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.

RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]

结束

相关推荐

如何防止WP覆盖我的自定义htaccess重写?

我使用了一些由Roots framework. 偶尔它们会被抹掉:当然,如果我访问设置>永久链接,也会在看似随机的时间。我的htaccess是这样读的:<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\\.php$ - [L] RewriteRule ^css/(.*) /wp-content/themes/the-hit-centre/css/