【问题标题】:Redirect www domain to http将 www 域重定向到 http
【发布时间】:2014-05-30 00:23:39
【问题描述】:

我很难将所有 www 请求重定向到 apache 中的 http。

在 http.conf 我有:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?test\.pt/.*)$
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

然后我配置了以下虚拟主机配置:

<VirtualHost *:80>
     ServerAdmin xxx@yyy.pt                                                                        
     ServerName test.pt
     DocumentRoot "/var/www/html/testjoomla"
</VirtualHost>

因此,如果我尝试访问:www.test.pt 或 www.test.pt/index.php/pt/ 它运行良好,它会重定向到 http://test.pthttp://test.pt/index.php/pt/ 但是如果我尝试访问 www.test .pt/index.php/pt 不起作用它保留 www.test.pt/index.php/pt ... 任何人都可以提供任何帮助吗?

最好的问候

【问题讨论】:

标签: apache apache2 virtualhost httpd.conf


【解决方案1】:

这是否可行?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?test\.pt.*)$
RewriteRule /(.*)$ http://%1/$1 [R=301,L]

【讨论】:

  • 奇数。这些是配置中唯一存在的重写规则吗?
  • 是的。正如我所说的那样,重定向适用于 www.test.pt 或 www.test.pt/index.php/pt/ 但不适用于 www.test.pt/index.php/pt
猜你喜欢
  • 2015-05-19
  • 1970-01-01
  • 2017-11-24
  • 2017-03-24
  • 2013-09-03
  • 1970-01-01
  • 2014-03-25
  • 2018-09-26
  • 1970-01-01
相关资源
最近更新 更多