【问题标题】:htaccess redirects not working on Apache serverhtaccess 重定向在 Apache 服务器上不起作用
【发布时间】:2018-02-06 16:31:58
【问题描述】:

我想将 非 www 重定向到网站的 www 版本。我已经重定向了许多网站,但从未遇到过这个问题。我在 Apache/2.4.27 (Ubuntu) 服务器上安装了典型的 WP。

我在# BEGIN WordPress之前放了以下代码

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301,NC]

我也试过了,没有结果。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite\.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301]
</IfModule>

我所做的一切,我得到:禁止 - 您无权访问此服务器上的 /。

如何使此重定向起作用?服务器端有什么需要注意的吗?

【问题讨论】:

  • wordpress 完全不一样,你以前有没有这样重定向过 wordpress 网站?

标签: wordpress apache .htaccess redirect


【解决方案1】:

您是否尝试过修改 httpd.conf? RedirectPermanent 是替换 .htaccess 如果不起作用的好选择。

示例:

<VirtualHost *:80>
ServerName xy.example.com
RedirectPermanent / http://abc.example.com/
# optionally add an AccessLog directive for
# logging the requests and do some statistics
</VirtualHost>

【讨论】:

    猜你喜欢
    • 2016-06-23
    • 2010-11-10
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 2013-01-25
    • 1970-01-01
    • 2017-05-17
    • 2015-03-20
    相关资源
    最近更新 更多