Reputation: 4755
I want to point ipv4 adress (51.255.51.165) and the VPS url server (vps227127.ovh.net) to just one domain.
I have tried with this rewrite rule in .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^vps227127.ovh.net$
RewriteCond %{HTTP_HOST} ^51\.255\.51\.165
RewriteRule (.*) http://krioma.com/$1 [R=301,L]
The second condition works fine, it redirects 301 to http://krioma.com, but it seems ignoring the first condition. Maybe I'm wrong something.
Any suggestions?
Upvotes: 1
Views: 158
Reputation: 24478
Typically if you don't specifically tell Apache you want either one, it will use the default AND
and both conditions would have to be true for it to work. You need to use the special OR
flag so that if either one is met, then proceed to the rewrite rule.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^vps227127.ovh.net$ [OR]
RewriteCond %{HTTP_HOST} ^51\.255\.51\.165
RewriteRule (.*) http://krioma.com/$1 [R=301,L]
Upvotes: 2
Reputation: 18671
Use:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^vps227127.ovh.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^51\.255\.51\.165
RewriteRule (.*) http://krioma.com/$1 [R=301,L]
Because without OR
it's implicit AND
Upvotes: 3