【问题标题】:Permalinks on Wordpress EC2Wordpress EC2 上的永久链接
【发布时间】:2012-08-30 20:31:07
【问题描述】:

我刚刚将我的博客从本地网络服务器转移到 Amazon EC2 Free Linux 服务器,现在似乎一切正常,除了永久链接,我禁用并重新启用它们,它仍然中断。

我试过运行脚本

sudo a2enmod rewrite

但它显示 a2enmod: command not found while logged into my server as ec2-user

任何帮助将不胜感激!

谢谢

【问题讨论】:

    标签: wordpress amazon-ec2 permalinks


    【解决方案1】:

    我刚刚遇到了同样的问题,假设您使用的是 httpd,您需要转到 /etc/httpd/conf,然后通过运行 sudo vi httpd.conf 打开 http.conf,然后将“AllowOverride”更改为:

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

    您可能还需要在此处更改AllowOverride All

    # 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
    

    然后您需要通过运行apachectl -k restart 重新启动httpd。请注意,您可能需要实际运行sudo apachectl -k restart

    如果有帮助,请告诉我。

    【讨论】:

    • 嗨,卡尔,非常感谢你!尤其是sudo apachecl -k restart 部分。在其他来源上找不到,非常沮丧……谢谢!
    • apachectl -k restart 对我不起作用,但 sudo service httpd restart 对我有用
    • 有一个朋友有类似的问题,她的配置略有不同。她的 wordpress 安装在 var/www/html/ 中,并且该特定目录的目录块中有一个 AllowOverride None 指令。在这种情况下,您需要在该特定文件夹的目录块中将 AllowOverride 指令设置为 All - 对于不使用 wordpress 的其他目录块,我建议将其留给 None .
    【解决方案2】:

    对于 Ubuntu,在以下位置更改“AllowOverride All”:

    “我必须采取的额外步骤是编辑 /etc/apache2/sites-enabled/000-default。

    在该文件中,您会发现 /var/www 的 AllowOverride 设置,即“无”。

    将设置更改为:AllowOverride All "

    感谢 ljonas@http://wordpress.org/support/topic/solved-permalinks-working-in-apache2-ubuntu-1010

    【讨论】:

      【解决方案3】:

      这里有书面和视频说明https://a1websitepro.com/enable-pretty-permalinks-amazon-web-hosting/

          <Directory /var/www/html/>
           Options Indexes FollowSymLinks
           AllowOverride All
          </Directory>
      

      【讨论】:

      • 链接说明解释说 .htaccess 必须进行编辑。其他帖子表明它只是 apache2.conf
      【解决方案4】:

      基本:Connecting to Your Linux Instance from Windows Using PuTTY

      第一步:打开PuTTY登录AWS EC2控制台

      第 2 步:输入服务器地址

      第 3 步:在 PuTTY 中浏览 Auth 私钥

      第 4 步:通过 PuTTY 登录 AWS(输入“Login as name”,即您的 AWS ec2 实例名称。例如:ec2-user)

      第 5 步:将目录更改为 /etc/httpd/conf ($ cd /etc/httpd/conf)

      第六步:执行sudo vi httpd.conf更新httpd.conf文件。 (在 VI 编辑器中打开 httpd.conf 文件)

      更新关注

      <Directory />
          Options FollowSymLinks
          AllowOverride None
      </Directory>
      

      <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 None
      

      # 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
      

      第 7 步:保存并退出 VI 编辑器。

      要保存并退出 VI 编辑器,请按 [Esc] 键并输入 :wq

      第 8 步:重启 Apache

      输入sudo apachectl -k restart

      最终截图

      【讨论】:

        【解决方案5】:

        在 AWS 上,我的文件位于稍微不同的位置:

        sudo nano /etc/httpd/conf/httpd.conf
        

        在两个位置将AllowOverride None 更改为AllowOverride All 并使用sudo service httpd restart 重新启动后,永久链接重定向效果很好!

        【讨论】:

          【解决方案6】:

          您的服务器可能没有启用 AllowOverride 指令。如果在 Apache httpd.config 文件中将 AllowOverride 指令设置为 None,则 .htaccess 文件将被完全忽略。

          在这种情况下,服务器甚至不会尝试读取文件系统中的 .htaccess 文件。当此指令设置为 All 时,任何具有 .htaccess 上下文的指令都可以在 .htaccess 文件中使用。 httpd.config 中启用 AllowOverride 指令的示例:

          Options FollowSymLinks

          AllowOverride All

          此链接也可能有帮助: http://codex.wordpress.org/Using_Permalinks

          【讨论】:

            【解决方案7】:

            AllowOverride 控制哪些指令可以放在 .htaccess 文件中。 它可以是“All”、“None”或关键字的任意组合: 选项 FileInfo AuthConfig 限制

            AllowOverride All
            

            当我在我的服务器上设置这个时,我得到了 503 内部服务器错误,请问有什么建议吗?

            【讨论】:

              【解决方案8】:

              我不得不在多个 .conf 文件中使用 AllowOverride All 和 Options +FollowSymLinks(我还尝试了 a2enmod rewrite)。但它是最后一个显然控制该目录的 .conf 文件(我们使用的 .iso 导致多个具有相同目录的文件......而我更改的第一个没有效果)。但是一旦他们都拥有这两个设置,系统就开始工作了。

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2018-04-17
                • 1970-01-01
                • 1970-01-01
                • 2023-03-14
                • 1970-01-01
                • 2012-04-06
                • 2020-03-16
                • 2017-06-26
                相关资源
                最近更新 更多