【问题标题】:Old Domain 301 Redirect to New Domain with HTAccess Wildcard旧域 301 使用 HTAccess 通配符重定向到新域
【发布时间】:2016-02-22 19:44:46
【问题描述】:

我有一个旧域名让我们称之为

example.com

我想对其所有页面及其主页进行 301 重定向到

newsite.com

例如

example.com/category/page.html

应该 301 重定向到

newsite.com/category/page.html

还有

example.com should redirect to newsite.com

www 或没有 www

我尝试了以下

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

我的文件夹结构是

index.html
.htaccess

当我进入网站时,无论是否使用通配符,它​​都只会加载 index.html 而 .htaccess 重定向不起作用。

我确实启用了 modrewrite

谁能指导我为此案例设置正确的 .htaccess。

谢谢!

【问题讨论】:

  • 您的评论“当我进入网站时,无论是否使用通配符,它​​都只加载 index.html”并不完全清楚。您能否澄清您在浏览器中输入的 URL 以及 index.html 文件正在加载的两个站点中的哪个站点?你会被重定向到newsite.com 还是留在example.com

标签: .htaccess redirect


【解决方案1】:

你也可以使用 RedirectMatch 指令。

在 Olddomain/.htaccess 中试试这个:

RedirectMatch ^/(.*)$ http://newsite.com/$1

【讨论】:

    猜你喜欢
    • 2013-09-23
    • 2012-10-13
    • 1970-01-01
    • 2012-04-03
    • 2020-06-15
    • 2020-07-10
    • 1970-01-01
    • 2016-06-24
    • 2011-11-04
    相关资源
    最近更新 更多