【问题标题】:Remove index.php in Wordpress subfolders when using virtual hosts使用虚拟主机时删除 Wordpress 子文件夹中的 index.php
【发布时间】:2013-08-14 12:58:37
【问题描述】:

我到处寻找解决此问题的方法,但我尝试过的任何方法都没有奏效。当将永久链接设置为 /index.php/%postname%/ 时,它工作正常,但是当我删除 index.php 部分时,我只得到一个 404,并且在日志中:

[Tue Aug 13 05:05:46 2013] [error] [client 202.58.198.84] File does not exist: /var/www/html/domain1/postname, referer:.....

我有一个通过虚拟主机运行 Apache 的 Red Hat 网络服务器,其中包含两个 Wordpress 站点。虚拟主机如下所示。

<VirtualHost *:80>
  # General
  ServerAdmin info@domain1.com
  DocumentRoot /var/www/html/domain1
  ServerName domain1.com
  ServerAlias www.domain1.com

  # Logging
  ErrorLog logs/domain1-error_log
  CustomLog logs/domain1-access_log common
</VirtualHost>

<VirtualHost *:80>
  # General
  ServerAdmin info@domain2.com
  DocumentRoot /var/www/html/domain2
  ServerName domain2.com
  ServerAlias www.domain2.com

  # Logging
  ErrorLog logs/domain2-error_log
  CustomLog logs/domain2-access_log common
</VirtualHost>

更改前端设置中的永久链接后,子文件夹中的 .htaccess 文件如下所示。

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

我也尝试过改变

RewriteBase /

RewriteBase /subfolder

运气不好。

这不是一个大问题,但它让我很烦恼!如果有人对此有解决方案,我将不胜感激。

【问题讨论】:

    标签: wordpress virtualhost redhat


    【解决方案1】:

    确保:

    • 您的 wordpress 永久链接设置为 /%postname%
    • .htaccess 文件放置在 /var/www/html/domain1 中(与 domain2 相同)
    • 像这样为 domain1/2 目录指定一些规则(在配置文件中的 &lt;/virtualhost&gt; 标记之前添加这段代码):

      <Directory /var/www/html/domain1>
              Options FollowSymLinks MultiViews
              AllowOverride All
              Order allow,deny
              allow from all
      </Directory>
      

    【讨论】:

      猜你喜欢
      • 2017-10-29
      • 2012-09-22
      • 1970-01-01
      • 2017-07-18
      • 2013-07-05
      • 1970-01-01
      • 2013-10-04
      • 2012-12-06
      • 2017-01-19
      相关资源
      最近更新 更多