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 9129185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:41:17+00:00 2026-06-17T07:41:17+00:00

I am trying to redirect all traffic into a subdomain. www.example.com, example.com, sub.othersite.com all

  • 0

I am trying to redirect all traffic into a subdomain.

http://www.example.com, example.com, sub.othersite.com
all rewrite to sub.othersite.com

It works great. Now I need to exclude a single URL from redirecting to the subdomain

So if http://www.example.com/THE/URI comes in, I want mod rewrite to ignore the subdomain rewrite and send it to the main domain.

Seems simple enough but I can’t get it to work because I have an additional rewrite that makes sure all the domains (there are a couple parked ones as well) funnel into a single domain to deliver the content.

I have a few other rewrite conditions. They are all listed here. If someone could point me in the right direction – I need to basically do this:

IF incoming request is for /THE/URI
then go to http://www.example.com/THE/URI
otherwise
rewrite to sub.othersite.com

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # ignore system folder
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteCond $1 !^(client/*)   
  RewriteRule ^(.*)$ /index.php?/$1 [L]

  #Checks to see if the user is attempting to access a valid file,
  #such as an image or css document, if this isn't true it sends the
  #request to index.php
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt|css)
  RewriteRule ^(.*)$ index.php?/$1 [L] 

  # if it is the SPECIAL URI redirect and EXIT
  RewriteCond $1 !^(/THE/URI)   
  RewriteCond %{HTTP_HOST} !^www.example.com$
  RewriteRule ^(.*)$ http://www.example.com/THE/URI [L]

  #catch all other traffic        
  RewriteCond %{HTTP_HOST} !^example.anothersite.com$
  RewriteRule ^(.*)$ http://example.anothersite.us/$1 


</IfModule> 
  • 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-17T07:41:18+00:00Added an answer on June 17, 2026 at 7:41 am

    Solved.
    The answer was simple. I just needed to exclude both the URI and the QUERY_STRING from the final rewrite, since the top half of the rewrite appends the URL with a query string.

    In order for my application to work, I still needed the initial rewrite (take any URI and internally map it to index.php?URI)

    Final code:

    <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
    
            #Removes access to the system folder by users.
            RewriteCond %{REQUEST_URI} ^system.*
            RewriteCond $1 !^(client/*)   
            RewriteRule ^(.*)$ /index.php?/$1 [L]
    
                    # our URL is prepped now - query string appended, so let's redirect it
                    # ONLY if it's not the ONE URL we need to keep
    
            RewriteCond %{REQUEST_URI} !^/THE/URI   
            RewriteCond %{QUERY_STRING} !^/THE/URI
            RewriteCond %{HTTP_HOST} !^sub.example.com$
            RewriteRule ^(.*)$ http://sub.example.com/$1  [R=302]
    </IfModule>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to redirect all requests for subdomain.example.com to www.example.com Options +FollowSymLinks RewriteEngine on
I'm trying to redirect all subdomain requests for domain.com to www.domain.com and user must
I'm trying to redirect all subdomain requests for domain.com to www.domain.com even when the
I'm trying to redirect all insecure HTTP requests on my site (e.g. http://www.example.com )
I want to use htaccess to redirect all traffic from www.oldsite.com/directory to www.newsite.com I
I am trying to redirect all requests to domain.com/drupal to domain.com, including all sub
What I'm trying to accomplish with htaccess mod-rewrite: Redirect all sub-domains to new domain
I'm trying to make a general rewrite rule to redirect all domain.com requests to
Trying to redirect all traffic from www.old-domain.co.uk and old-domain.co.uk to www.new-domain.co.uk on a Wordpress
I am trying to redirect all my website traffic at mydomain.com to mynewdomain.net. Both

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.