开发者

How do I replace the domain name in a Apache Rewrite rule?

开发者 https://www.devze.com 2023-03-28 23:42 出处:网络
I need to redirect a URL domain.com to domain.net in a Rewri开发者_StackOverflowte rule. I originally used redirect, but it lost the POST variables I was sending. Will a Rewrite carry them over and wh

I need to redirect a URL domain.com to domain.net in a Rewri开发者_StackOverflowte 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]
0

精彩评论

暂无评论...
验证码 换一张
取 消