Reputation: 143
Please let me know if i request using 127.0.0.1/xyz then i should redirect to different site using apache reqwrite condition rules.. Can you please shed your info on this? My question is similar to this Restrict access to website from its ip address.
Upvotes: 1
Views: 3928
Reputation: 143
It is redirecting properly if I browse the site by IP address.
Hope this will help others.
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^127\.0\.0\.1$
RewriteRule ^ http://localhost.com/xyz [R=301,L]
</VirtualHost>
Upvotes: 0
Reputation: 603
Use below rule in your Virtual Host configuration.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^127\.0\.0\.1$
RewriteCond %{REQUEST_URI} ^/xyz$ [NC]
RewriteRule ^ http://url.todifferentsite.com [R=301,L]
Upvotes: 0
Reputation: 625
As of i have personally used this logic from front end there are two ways:
if you wanted to do it using JavaScript
if(window.location.host == "10.20.29.162:8080")
{
window.location.href = "http://example.com/new_url";
}
above logic will check for the host name for example your ip address is "10.20.29.162:8080" then your page will be moved to "http://example.com/new_url" URL
it can be done with the metatag as well
<meta http-equiv="refresh" content="1;URL=http://example.com/new_url">
You just need to check from the backed if host is IP put this meta tag at the header.
there might be some more way to handle it from the backend.
hope this helps
Upvotes: 0
Reputation: 51
To block specific users having IP address w.x.y.z
, you can configure your .htaccess
file.
Read more about .htaccess
here : http://en.wikipedia.org/wiki/.htaccess
order allow,deny
deny from w.x.y.z
allow from all
Upvotes: 1