.htaccess - Htaccess : redirect from old domain to new

标签 .htaccess

我有一个 olddomain.com 需要指向 newdomain.com

所以如果有人试图输入 oldomain.com/whatever 他们会进入 newdomain.com

我不想准确地映射旧的 url,所以我已经尝试过

RewriteEngine On
Redirect 301 / http://www.newdomain.com

但如果我尝试使用它效果不佳

oldomain.com/whatever  

网址出现在浏览器中:

newdomain.comwhatever 

(没有/)

最佳答案

这应该有效:

RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,NC]

关于.htaccess - Htaccess : redirect from old domain to new,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29747641/

相关文章:

.htaccess - .htaccess 中的这个文件是什么?

php - 浏览器同步 - PHP 和 htaccess?

wordpress - 如果任何目录具有特定的查询字符串,则重定向该目录

html - HTTP 到 HTTPS 重定向不适用于 .htaccess

php - htaccess 基于查询字符串的 url

.htaccess - htaccess 带空格的文件名损坏

.htaccess opencart 重定向 301

.htaccess - 想要将域重定向到子文件夹中的博客,直到完整站点启动

.htaccess - Magento 2.2.2 错误.htaccess IfVersion 2.4

php - 如何增加 cPanel 中的最大上传大小?