apache - htaccess 将所有页面重定向到单个页面

我想使用 htaccess 文件将我所有的旧域请求重定向到我的新域。以下是我正在使用的内容,但如果该页面不在新站点上,则它不起作用。例如,旧站点上的 google index about.htm 但在新站点上它不存在。我希望它在所有情况下都进入根目录。我知道这对 seo 来说并不理想,但我不想要任何 404。有什么建议?

Redirect 301 / http://www.thenewdomain.com/

最佳答案

您是否试图让 old.com/about.htm 的访问者转到 new.com/about.htm?如果是这样,您可以使用 .htaccess 中的 mod_rewrite 规则执行此操作:

RewriteEngine on

RewriteRule ^(.*)$ http://www.thenewdomain.com/$1 [R=permanent,L]

https://stackoverflow.com/questions/3522921/

相关文章:

c++ - C++如何向minGW添加库

Excel VBA 错误 - 函数或接口(interface)标记为受限。或函数使用 Visual

compilation - 安装MPFR(3.1.0)时出错

c++ - 编译器错误 : Undefined symbols for architecture x

iphone - NSInvalidArgumentException与UITableView吗?

c++ - OpenCV无法编译

ios - iOS静态库取决于其他静态库

java - Java : Longest Ascending substring

java - 升序子字符串编译错误

android - NDK错误: “can' t resolve `.data.rel.ro.loc