【问题标题】:Install WordPress in its own directory but permalink fails在自己的目录中安装 WordPress,但永久链接失败
【发布时间】:2011-10-06 15:13:34
【问题描述】:

我在 EC2 上安装了 WordPress,位于 /var/www/html/wordpress。我按照 WordPress 指南将 index.php 和 .htaccess 复制到根目录 /var/www/html,并修改了 index.php 和管理面板中的设置。如果我只坚持默认链接,它会很好地工作,例如:http://www.cubcanfly.com/?p=5,但是其他永久链接选项失败,实际上是所有永久链接选项。

我的 .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>

/etc/httpd/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

没有评论。

提前致谢

【问题讨论】:

    标签: wordpress .htaccess amazon-ec2 rewrite permalinks


    【解决方案1】:

    终于找到问题所在了。这是httpd.conf中的AllowOverride选项,位于/etc/httpd/conf/httpd.conf,“sudo find / -name httpd.conf -print”可以很容易地找到它。 我更改了我可以在文件中找到的任何 AllowOverride NONE->ALL。它只是工作,即使没有对 .htaccess 做任何更改

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

    这个 .htaccess 在我的主机上工作,其中 wordpress 安装在它自己的目录中。

    谢谢@adlawson @Will,没有你,我找不到问题。

    http://codex.wordpress.org/Using_Permalinks这个官方指南足以使用永久链接,即使 wordpress 安装在子目录中。

    【讨论】:

      【解决方案2】:

      看看这个帖子How does RewriteBase work in .htaccess

      您需要将RewriteBase / 更改为RewriteBase /wordpress

      【讨论】:

      • 别忘了把最后一个 RewriteRule 改成 /wordpress/index.php。
      • @adlawson @Will 我将 .htaccess 更改为 ... RewriteBase /wordpress...RewriteRule 。 /wordpress/index.php [L] 和永久链接仍然不起作用,感谢您的帮助。
      • @adlawson @Will 谢谢你的帮助,我终于找到了这里发生的事情。我没有在 httpd.conf 中启用 AllowOverride。一旦我将它设置为全部,它就可以很好地与我在主线程中发布的 .htaccess 文件一起使用。我们实际上不需要做任何事情 ^_^ 干杯。
      【解决方案3】:

      我不需要在 .htaccess 中编辑 RewriteBase。 问题确实出在 EC2 机器的 httpd 配置中。

      我的 .htaccess -

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

      在 /etc/httpd/conf/httpd.conf -

      <Directory />
          Options FollowSymLinks
          AllowOverride All
      </Directory>
      
      # AllowOverride controls what directives may be placed in .htaccess files.
      # It can be "All", "None", or any combination of the keywords:
      #   Options FileInfo AuthConfig Limit
      #
      AllowOverride All
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-08
        • 1970-01-01
        • 1970-01-01
        • 2021-04-15
        • 2021-09-15
        相关资源
        最近更新 更多