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

  • SEARCH
  • Home
  • 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 7854991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:15:02+00:00 2026-06-02T20:15:02+00:00

How to shorten this expression? i want instead of using 2 lines just check

  • 0

How to shorten this expression? i want instead of using 2 lines just check whatever domain is something different from mysite.com e.g. mysite.org or http://www.mysite.org with or without www and redirect.

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^mysite\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mysite\.org$ [OR]
RewriteCond %{HTTP_HOST} ^mysite\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mysite\.net$

RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]

Also is it faster to use [OR] or do like this

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

P.S. why this works as case insensetive even when i dont use [NC]?

  • 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-02T20:15:03+00:00Added an answer on June 2, 2026 at 8:15 pm

    You may want to check Apache documentation on canonical hostnames, your rules can be expressed as a negation

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

    And for the rules matching without [NC] , it probably depends on what the browser sends to the server.

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

Sidebar

Related Questions

Following on from this question I asked yesterday: Can I shorten this regular expression?
How can i shorten this code? I want to return all values except abc
This is a easy question,but I just don't get it. I want to detect
I want to calculate a boolean expression like this ((('a' or 'b') AND ('c'
I'm trying to shorten a wordpress title to just the first word. For a
Is there a way to shorten type names in java. Something similar to typedef
I am using php to create url shorten website. Within that script I am
I have a series of numbers of different lengths (varying from 1 to 6
How can I shorten this code? Each css selector increases +1. All Bio's divs
I wanted to know if there was a way to shorten this if statement

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.