Filip Frątczak
Filip Frątczak

Reputation: 157

Redirect all traffic to temporary domain with 307 redirection

I'm trying to redirect the traffic to my temporary adress. Im using httaccess file to do that. That's the content of it:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^old.domain$
RewriteRule (.*)$ http://new.domain/$1 [R=307, L]

It works if I enter adress: http://old.domain but it won't work with http://old.domain/somenting. It sends then 500 error. If I change R=307 to R=301 it works but I need 307 redirection.

Upvotes: 5

Views: 7229

Answers (2)

Chrisitna
Chrisitna

Reputation: 1

You can try this:

   RewriteEngine on 
   RewriteCond   %{HTTP_HOST} old\.domain [NC]
   RewriteRule   ^/(.*)$      http://new.domain/$1 [R=307,L]

Upvotes: 0

Jon Lin
Jon Lin

Reputation: 143936

Those rules work fine for me, but there's a syntax error in your rewrite rule's flags. You can't have a space after the comma:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^old.domain$
RewriteRule (.*)$ http://new.domain/$1 [R=307,L]
# no space here-------------------------------^

Upvotes: 6

Related Questions