如何在Apache Rewrite规则中替换域名? [英] How do I replace the domain name in a Apache Rewrite rule?

查看:242
本文介绍了如何在Apache Rewrite规则中替换域名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要按照重写规则将URL domain.com重定向到domain.net。我最初使用重定向,但是丢失了我正在发送的POST变量。 Rewrite会保留它们吗,什么是最好的方法?

I need to redirect a URL domain.com to domain.net in a Rewrite rule. I originally used redirect, but it lost the POST variables I was sending. Will a Rewrite carry them over and what is the best way to do this?

推荐答案

这应该可以解决您的问题:

This should resolve your problem:

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

这篇关于如何在Apache Rewrite规则中替换域名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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