Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8053585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:53:52+00:00 2026-06-05T07:53:52+00:00

I have 2 different domains on the same server: domain1.com and domain2.com on server

  • 0

I have 2 different domains on the same server:
domain1.com and domain2.com on server address 100.12.12.222
and simple redirection rule for non-www to www

RewriteCond %{HTTP_HOST} !^www\.    
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

and I’d like to have a rule like: if host=domain1.com then redirect to http://www.domain1.com
and if host=100.12.12.222 don’t redirect to http://www.domain1.com

I tried to add:

RewriteCond %{REMOTE_ADDR} ^100\.12\.12\.222
RewriteRule (.*) http://100.12.12.222/$1 [R=301,L]

which works if the second domain doesn’t have non-www to www redirection

so I googled and read apache advices and tried to combine something like:

RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{REMOTE_ADDR} !^100\.12\.12\.222
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

here I tried to use HTTP_HOST and various things, but it doesn’t redirect right.
Your help would be very appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:53:56+00:00Added an answer on June 5, 2026 at 7:53 am

    Drop the [or] flag. You want to redirect to www. if the host is not www... and the remote != 100.12.12.222

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two domains that are aliases, domain1.com and domain2.com Currently they are both
I have several sites in different domains: example.com , example.org , mail.example.com and passport.example.org
I have a virtual server with one IP address, serving a few different sites.
I have three Domains that resolve to the same Public IP Address but I
We have some large sites on different domains. Let's say x.com and y.com, they
We have several different domains hosted on an in-house server. They all represent different
I have two different domains (let's say www.site1.com and www.site2.com) that point to the
Redirecting to different server but same domain. I have 2 servers on different hosts.
i have two .net web application and they ara running on different domain same
I would like to have different applications under the same domain using Heroku. Because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.