【问题标题】:Wordpress permalink 'not found on this server'Wordpress 永久链接“在此服务器上找不到”
【发布时间】:2013-09-26 03:13:00
【问题描述】:

我刚刚将一个 Wordpress 网站移到了新主机上。但是当我转到除 HOME 页面之外的任何页面时,我得到了这个错误:

Not Found

The requested URL /about was not found on this server.

Apache/2.2.16 (Debian) Server at 176.xx.yy.zz Port 80

我将永久链接设置更改为默认,这使 URL 看起来像 mysite.com/?page_id=5 并且页面显示正常。所以问题不在我的代码中。

我的第一个猜测是 mod_rewrite 未启用。但phpinfo() 告诉我mod_rewrite 已正确加载。

我的 .htaccess 是自动生成的,看起来像:

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

有什么办法吗?

谢谢

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    假设您的 .htaccess 文件已就位,这很可能是由于您的新服务器上未启用 Apache 重写模块造成的。在 Ubuntu 上这样做:

    sudo a2enmod rewrite
    sudo apache2ctl restart
    

    【讨论】:

      【解决方案2】:

      您需要编辑您的 Apache http.conf 文件和

      更改#LoadModule rewrite_module modules/mod_rewrite.so

      LoadModule rewrite_module modules/mod_rewrite.so

      在不再存在 http.conf 的 Apache2 版本(即 ubuntu)上,您可以使用命令 a2enmod rewrite 来启用该模块。

      【讨论】:

      • 感谢您的回答。如果mod_rewrite 显示在phpinfo() 上,应该已经取消注释了吧?我无法查看http.conf,因为我无权访问它。
      • 我没有 httpd.conf 或任何加载 #LoadModule rewrite_module 的文件。我 grepped 了整个服务器。
      【解决方案3】:

      我相信这也可能是因为这三个问题。

      1. AccessFileName .htaccess 在您的 apache 配置中被注释。
      2. 您的 apache 配置中未针对 wordpress 路径提及 AllowOverride ALL。

      【讨论】:

      • 对于 Apache 2.4.6,AllowOverride None 是 httpd.conf 中给出的。我将其更改为 AllowOverride All 并且永久链接开始工作。
      【解决方案4】:

      这很简单,运行:

      shell > a2enmod rewrite enable
      

      如果你在 apache2 上运行。

      【讨论】:

        【解决方案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>
        # END WordPress
        

        这对我有用。

        【讨论】:

          猜你喜欢
          • 2017-08-22
          • 2014-02-10
          • 2016-07-19
          • 1970-01-01
          • 2018-01-03
          • 2016-12-09
          • 2018-11-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多