Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a WHM/cpanel server with about 200 sites on it. Most sites have a dedicated ip (about 100 of them) The other sites are on a shared ip.

The dedicated sites can be accseed by the ip address eg,

Is there a way to set up a mass redirect so that every site on a dedicated ip gets it's ip address redirected to the domain. E.g just make the default behavior of the web server to redirect an IP to the corresponding domain.

I know you can do this for each site via .htaccess or apache config file, but I want to avoid having to modify 100 sites, and have to do it again every time i create a new account.

share|improve this question
In all my cPanel servers, the dedicate IP automatically redirects to the corrisponding domain without any particular config. Which WHM version are you using? – Mr Shunz Mar 6 '11 at 11:20

Someone can correct me when I am wrong here, but I do not believe an easy solution/button exists for such a thing.

As you mentioned, .htaccess is a solution. Another solution would be to edit the virutalhost entires in your Apache log as such:


    RewriteCond %{SERVER_NAME}
    RewriteRule /(.*)$1 [R=301,L]

Of course you can automate this using bash, perl or any other scripting language you would like. For new accounts that contain a dedicated IP address, you can always use cPanel/WHM API for this sort of thing: post/pre ww account creation

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.