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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:25:11+00:00 2026-05-22T19:25:11+00:00

I am running WordPress 3.1 with multisite enabled. I have multiple websites all sharing

  • 0

I am running WordPress 3.1 with multisite enabled. I have multiple websites all sharing the same .htaccess file in the web root directory. I am using RewriteCond to target specific websites and apply RewriteRules to each site. Unfortunately it is not working as expected. Here is what I have in my .htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# Blog1 Rewrite Rules which should only apply to blog1.mydomain.com
RewriteCond %{HTTP_HOST} ^blog1\.mydomain\.com [nc]
RewriteRule ^fileabc\.jpg$ http://blog1.mydomain.com/files/2011/05/fileabc.jpg [R=301,NC,L]
RewriteRule ^filexyz\.pdf$ http://blog1.mydomain.com/wp-content/themes/blog1Theme/Files/filexyz.pdf [R=301,NC,L]

# Blog2 Rewrite Riles which should only apply to blog2.com
RewriteCond %{HTTP_HOST} ^Blog2\.com [nc]
RewriteRule ^index\.html$ http://Blog2.com/index.php [R=301,NC,L]
RewriteRule ^page\.html$ http://Blog2.com/page/ [R=301,NC,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

I use RewriteCond to target a specific site (blog1.mydomain.com or blog2.com) and they have specific RewriteRules for each.

However, The ReWriteRules are being applied to both websites (blog1.mydomain.com and blog2.com).

For example:

Accessing blog1.mydomain.com/fileabc.jpg should redirect to http://blog1.mydomain.com/files/2011/05/fileabc.jpg

However, accessing Blog2.com/fileabc.jpg also redirects to http://blog1.mydomain.com/files/2011/05/fileabc.jpg

So the RewriteRules are being applied to both (all) site, not just the ones specified by the RewriteCond.

Help is much 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-05-22T19:25:12+00:00Added an answer on May 22, 2026 at 7:25 pm

    From Apache page

    The order of rules in the ruleset is
    important because the rewrite engine
    processes them in a particular (not
    always obvious) order, as follows: The
    rewrite engine loops through the
    rulesets (each ruleset being made up
    of RewriteRule directives, with or
    without RewriteConds), rule by rule.
    When a particular rule is matched,
    mod_rewrite also checks the
    corresponding conditions (RewriteCond
    directives). For historical reasons
    the conditions are given first, making
    the control flow a little bit
    long-winded.

    first the URL is matched against the
    Pattern of a rule. If it does not
    match, mod_rewrite immediately stops
    processing that rule, and goes on to
    the next rule. If the Pattern matches,
    mod_rewrite checks for rule
    conditions. If none are present, the
    URL will be replaced with a new
    string, constructed from the
    Substitution string, and mod_rewrite
    goes on to the next rule.

    Now your rules

    RewriteCond %{HTTP_HOST} ^blog1\.mydomain\.com [nc]
    RewriteRule ^fileabc\.jpg$ http://blog1.mydomain.com/files/2011/05/fileabc.jpg [R=301,NC,L]
    RewriteRule ^filexyz\.pdf$ http://blog1.mydomain.com/wp-content/themes/blog1Theme/Files/filexyz.pdf [R=301,NC,L]
    

    RewriteCond is valid only for first rewriteRule immediately following it , not for all rules below it.So second rewriteRule will match any domain.

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

Sidebar

Related Questions

I have in my site a Wordpress running in the root directory, ie: mysite.com/
I have two WordPress blogs running on the same server, so they both have
I have to upgrade a running wordpress site's wordpress CMS and some installed plugins.and
I'm running a wordpress blog and would like to access the actual file that
If you want to develop against WordPress (i.e., have a local instance running on
Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have
I have been making Wordpress themes for a year or two and keep running
I'm trying to set up WordPress. I have Apache and MySQL running, and the
I'm using the FLIR for Wordpress plugin (v0.8.9.2) with FancyFonts enabled. I'm running Wordpress
I have a site running on WordPress. I am testing out a new site

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.