LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   accessing website with apache only by domain name (https://www.linuxquestions.org/questions/linux-server-73/accessing-website-with-apache-only-by-domain-name-4175455129/)

call_krushna 03-22-2013 10:01 AM

accessing website with apache only by domain name
 
Hi Team,

Need to block accessing our site using ip address .

It should be only accessible with name i.e www.goodworks.com and it should not be availabe with ip address .

My server ip 10.0.0.50 .

I have tried like , created a .htaccess and added

order allow,deny
deny from 10.0.0.50
allow from all

Not working .

My purpose is ,if somebody hits the ip 10.0.0.50 ,nothing should come in browser .

Any help is highly appreciable .
thanks in advance .

acid_kewpie 03-22-2013 10:28 AM

that's absolutely NOT what the allow statement is for.

There are plenty of ways to do this, mod_rewrite or some such. Personally I'd suggest using a dumym default virtualhost, especially if you already have the site correctly set up with a a virtualhost anyway.

When you request a website with a virtualhost, apache will match the provided hostname to the apporpriate virtualhost definition. If none matches (e.g. if you only use an IP) then the FIRST ONE is used. So if that first one doesn't contain any content, then that's what they'll get.

call_krushna 03-22-2013 10:43 AM

Quote:

Originally Posted by acid_kewpie (Post 4916575)
that's absolutely NOT what the allow statement is for.

There are plenty of ways to do this, mod_rewrite or some such. Personally I'd suggest using a dumym default virtualhost, especially if you already have the site correctly set up with a a virtualhost anyway.

When you request a website with a virtualhost, apache will match the provided hostname to the apporpriate virtualhost definition. If none matches (e.g. if you only use an IP) then the FIRST ONE is used. So if that first one doesn't contain any content, then that's what they'll get.

Is the following block fine in adding virtualhost which will redirect any request to fqdn name

RewriteEngine on
RewriteRule ^/(.*)$ http://www.goodworks.com/$1 [R,L]


All times are GMT -5. The time now is 08:47 AM.