【问题标题】:how load wordpress in a subdirectory without wordpress in root directory taking over如何在没有根目录中的wordpress接管的情况下在子目录中加载wordpress
【发布时间】:2016-07-13 08:51:53
【问题描述】:

我的生产 Wordpress 网站位于 example.com.au,从 /public_html 运行

我还有一个独立的 Wordpress 站点,位于 /public_html/mainwp 子目录中,运行 Main WP

/public_html 中的.htaccess 是:

# Begin Wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# End Wordpress

如果我尝试加载 example.com.au/mainwp/wp-admin,我会收到由 Wordpress 在 example.com.au 提供的 404

如果我将 /public_html/.htaccess 重命名为 .htaccess.tempexample.com.au/mainwp/wp-admin 加载正常。

周末发生了一些变化,我不知道是什么。我很确定这个 .htaccess 在周末之前工作。

帮助表示赞赏。

更新:根据 Sagar 的回答,我已经确认 /public_html/mainwp/.htaccess 包含以下代码:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mainwp/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mainwp/index.php [L]
</IfModule>
# END WordPress

以前这种情况有效,但现在不行:example.com.au/mainwp/wp-admin 提供由 Wordpress 在example.com.au 提供的 404 服务

【问题讨论】:

  • 主文件夹中的安装是多站点的吧?
  • 是的,它是@McNab - 一个子目录多站点

标签: wordpress .htaccess


【解决方案1】:

请在子目录 .htaccess 文件中使用以下代码。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /newsite/index.php [L]
</IfModule>
# END WordPress

更多信息请查看Link

【讨论】:

  • 谢谢,Sagar 已修复。我不明白为什么,因为它已经有了那个代码,然后只有.htpasswd 保护。恢复这个原始的.htaccess 并没有破坏/mainwp/wp-admin,即使网络根目录中的.htaccess 仍然处于活动状态,所以我很困惑。
  • WordPress一般会在安装目录下写一个.htaccess文件,这个文件夹一般是网站根文件夹。这就是您遇到问题的原因。
  • 当然。不过,这并不能解释我在上面的评论中写的内容。
  • 对于 mainwp,检查 /mainwp/.htacess,对于 newsite wordpress,检查 /newsite/.htacess。因此,当我们查看 newsite .htacess 时,它将调用 mainwp 站点。这就是它中断的原因。
猜你喜欢
  • 2017-10-08
  • 2012-10-08
  • 2014-02-15
  • 2012-08-27
  • 2015-08-05
  • 2012-02-03
  • 2011-01-31
  • 2018-02-05
  • 1970-01-01
相关资源
最近更新 更多