【问题标题】:how to redirect non-www to www on aws lightsail using route 53如何使用路由 53 将非 www 重定向到 aws lightsail 上的 www
【发布时间】:2022-08-19 17:41:17
【问题描述】:

我尝试通过 .htaccess 进行重定向。似乎 .htaccess 文件没有被 AWS-lightsail 读取或处理,而是使用 WordPress 中的重定向插件进行重定向。它也不起作用。 www 和非 www 都可以访问,但不是 google 用于 google 分析。如果有任何解决方案来解决这个问题。请指导我。

    标签: php wordpress amazon-web-services http-redirect amazon-lightsail


    【解决方案1】:

    假设您使用的是 bitnami(通常用于使用 AWS 设置 WordPress):

    nano /opt/bitnami/apps/wordpress/conf/httpd-app.conf
    

    在下面:

    <Directory "/opt/bitnami/apps/wordpress/htdocs">
    

    改变:

    AllowOverride None
    

    至:

    AllowOverride All
    

    或者,在同一个文件中,您可以添加:

    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule ^https://example.com%{REQUEST_URI} [L,NE,R=301]
    

    希望这可以帮助。

    【讨论】:

      猜你喜欢
      • 2018-07-21
      • 2016-02-22
      • 2020-03-31
      • 2017-05-30
      • 1970-01-01
      • 2017-07-11
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多