htaccess:将所有请求重定向到其他域(无查询参数) [英] htaccess: redirect all requests to different domain (without query arguments)

查看:81
本文介绍了htaccess:将所有请求重定向到其他域(无查询参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将sub.domain.com上的所有请求(无论请求哪个页面)重定向到newdomain.com?目前,我有

How can I redirect all requests (irrespective of what page is being requested) on sub.domain.com to newdomain.com? Currently I have

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

当对domain.com/shop/product提出请求时,重定向将转到newdomain.com/shop/product,而重定向则应转到newdomain .com

When a requests comes in for domain.com/shop/product the redirect goes to newdomain.com/shop/product while it should just go to newdomain.com

推荐答案

使用重写:

RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/ [R=301,L]

这篇关于htaccess:将所有请求重定向到其他域(无查询参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆