【问题标题】:Updating httpd.conf not working for permalinks更新 httpd.conf 不适用于永久链接
【发布时间】:2021-03-29 17:49:33
【问题描述】:

我无法将永久链接设置为以帖子名称结尾。我收到 404 错误。我得到的最接近的是将自定义永久链接设置为:

/index.php/%postname%

但这会导致“index.php”出现在 URL 中。我还更新了我的 httpd.conf 以将根目录设置为:

AllowOverride All

但它仍然不起作用。我的 wordpress 托管在 AWS EC2 linux AMI 上。

【问题讨论】:

    标签: wordpress http-status-code-404 httpd.conf permalinks


    【解决方案1】:

    激活 mod_rewrite 模块

    sudo a2enmod rewrite
    

    然后重启apache

    sudo service apache2 restart
    

    要在 .htaccess 文件中使用 mod_rewrite(这是一个非常常见的用例),请编辑默认的 VirtualHost

    sudo nano /etc/apache2/sites-available/000-default.conf
    

    在“DocumentRoot /var/www/html”下面添加以下行:

    <Directory “/var/www/html”>
    AllowOverride All
    </Directory>
    

    再次重启服务器:

    sudo service apache2 restart
    

    编辑:

    发现我的 htaccess 文件丢失了。所以按照这里列出的步骤:

    https://wordpress.org/support/article/using-permalinks/#wheres-my-htaccess-file

    • 在 wp root 中创建了 htaccess,在我的服务器上是 /var/www/html。
    • 添加了上面链接中提供的所需重写规则。
    • 将 htaccess 上的 chmod 设置为 775
    • 在 htaccess 上将 chown 设置为 apache:apache
    • 重启httpd服务

    邮名固定链接现在可以使用了!

    【讨论】:

    • 我使用的 AMI 有 httpd 服务而不是 apache2。因此,这些步骤不适用。
    • 您是否尝试过以下步骤:devops.ionos.com/tutorials/…
    • 谢谢!!!您的链接没有确切的解决方案,但它表明我缺少 .thaccess 文件。 mod_rewrite 已启用。我只需要创建 htaccess。我将使用其他步骤更新您的答案并接受它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 2013-06-18
    • 2012-10-30
    • 1970-01-01
    相关资源
    最近更新 更多