【问题标题】:Redirection from a directory with www to the same directory without www从带 www 的目录重定向到不带 www 的目录
【发布时间】:2011-06-27 22:07:05
【问题描述】:

我想做一个永久的 301 重定向: 从所有的html文件 example.com/directory/ 到所有的 html 文件 www.example.com/directory/

【问题讨论】:

  • 你在用什么? PHP?
  • 所有pzges都是html页面。我正在使用 .htaccess 文件进行重定向(在 Apache 服务器上)

标签: redirect


【解决方案1】:

从无数网站窃取,在快速谷歌搜索“htaccess remove www”后,

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

【讨论】:

  • 感谢您的及时回复。
  • 感谢您的及时回复。我的目标是将 www 添加到使用此类 www 键入的任何 url。我目前正在使用以下内容: RewriteCond %{HTTP_HOST} 上的 RewriteEngine !^www\.example\.fr$ [NC] RewriteRule ^(.*)$ example.com/$1 [R=301,L] 不幸的是,它只适用于将 example.com 重定向到 www.example.com 但是将 example.com/directory/anyfile.html 重定向到 www.example.com/directory/anyfile.html 重定向 example.com/directory/anyfile 的任何想法。 html 到 www.example.com/directory/anyfile.html ?
猜你喜欢
  • 2010-10-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多