【问题标题】:Wordpress Permalinks does not workWordpress 永久链接不起作用
【发布时间】:2015-07-03 23:15:41
【问题描述】:

我已将 WordPress 网站迁移到运行良好的新服务器 (Ubuntu)。

但是永久链接设置不起作用。所有其他页面都返回 404 错误。

我已经启用mod_rewrite

当我使用自定义结构并键入 /%postname% 时,它会显示 永久链接结构已更新。 并且在访问页面时返回 404 错误。

我正在使用 /var/www/html/wordpress 安装目录/ 作为文件夹,并且我已更改 /etc/apache2/sites-available/000-defaul-config强>到

DocumentRoot /var/www/html/wordpress 安装目录

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

知道有什么问题吗?

【问题讨论】:

  • 检查wordpress文件夹sudo chown www-data:www-data -R wordpresssudo chmod -R 777 wordpress的权限
  • 我已授予上述权限。还是不行
  • 删除.htaccess文件一次,然后转到永久链接并再次提交
  • 我又做了一次。仍然没有为我工作。它再次使用与上面相同的代码创建了一个 .htacess 文件
  • 好的,但不要自己创建htaccess,htaccess是在提交永久链接时创建的。试一次

标签: php wordpress apache .htaccess mod-rewrite


【解决方案1】:

WordPress 永久链接修复

  1. 打开phpMyAdmin

  2. 找到您的 WordPress 数据库。

  3. 查找wp_options 表。

  4. 找到permalink_structure设置值为空白

  5. 如有必要,在您的 .htaccess 中隐藏/评论 modrewrite 行 您的 WordPress 处于普通永久链接模式

如果modrewrite 未激活且交互式设置不起作用。

【讨论】:

    【解决方案2】:

    对于像我这样在启用 mod-rewrite 的永久链接方面遇到问题的人,vhost 中的 AllowOverride All 以及 .htaccess 中的所有良好指令。

    我花了几个小时才发现我将 AllowOverride All 放在了 http (:80) 的虚拟主机中,但没有放在 https (:443) 的虚拟主机中。

    希望这将为您节省一些时间。 =)

    【讨论】:

      【解决方案3】:

      Wordpress 固定链接修复

      1.打开phpmyadmin。

      2.找到你的wordpress数据库。

      3.查找 wp_options 表。

      4.检查前两个字段并使用正确的 wordpress 位置更新 option_value。

      5.重新加载永久链接。

      【讨论】:

        【解决方案4】:

        试试https://codex.wordpress.org/Using_Permalinks#Fixing_Other_Issues

        AllowOverride 未启用 您的服务器可能没有启用 AllowOverride 指令。如果在 Apache httpd.config 文件中将 AllowOverride 指令设置为 None,则 .htaccess 文件将被完全忽略。在这种情况下,服务器甚至不会尝试读取文件系统中的 .htaccess 文件。当此指令设置为 All 时,任何具有 .htaccess 上下文的指令都可以在 .htaccess 文件中使用。 httpd.config 中启用 AllowOverride 指令的示例:

        <Directory />
            Options FollowSymLinks
            AllowOverride All
         </Directory>
        

        您可能还必须在 DocumentRoot 中启用 AllowOverride 指令:

        <Directory /var/www/html>
            # ... other directives...
            AllowOverride All
         </Directory>
        
        You may also have to change the AllowOverride settings for the site. This is surely the case when using Mac OS X Server, but might be likewise with other systems. Usually you can find the site configuration files in /etc/httpd/sites/ 
        
        If you don't want to set AllowOverride to all (as it is above) then your AllowOverride list must include the FileInfo directive. You must restart your Apache server for any httpd.config file changes to take effect. For more information on which overrides are allowed, read about Apache Core Features. 
        

        【讨论】:

          猜你喜欢
          • 2011-05-18
          • 1970-01-01
          • 2018-04-17
          • 2015-04-28
          • 2016-12-07
          • 2015-08-22
          相关资源
          最近更新 更多