Title: Multisite redirect issue
Last modified: January 31, 2021

---

# Multisite redirect issue

 *  Resolved [Irene](https://wordpress.org/support/users/arlinaite/)
 * (@arlinaite)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/)
 * My site structure is main site “mysite” and two subfolders sites /es/ and /en/
 * mysite.com redirects => mysite.com/es/
 * What is wrong: mysite/non-existing-page redirects => mysite.com/es/
    Some part
   of this main redirect is causing that every non-existing page inside mysite.com(
   This site is empty) is redirected to the main page which is in the subdomain 
   mysite.com/es/ instead of getting a 404 error. I see where is the problem but
   I don’t know how to modified the rule
 * My redirect in the htaccess file:
 *     ```
       # Main Redirect
       RewriteEngine On
       RewriteCond %{HTTP_HOST} ^mysite\.com$ [OR]
       RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
       RewriteRule ^/?$ "https\:\/\/mysite\.com\/es\/" [R=301,L]
   
       RewriteCond %{HTTP_HOST} ^mysite\.com$ [OR]
       RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
       RewriteRule ^index\.html$ "https\:\/\/mysite\.com\/es\/" [R=301,L]
   
       RewriteCond %{HTTP_HOST} ^mysite\.com$ [OR]
       RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
       RewriteRule ^indexingles\.html$ "https\:\/\/mysite\.com\/en\/" [R=301,L]
       ```
   
 * Works perfect for the following:
    Is perfect that mysite.com/ redirects => mysite.
   com/es Is perfect that index.html redirects => mysite.com/es Is perfect that 
   indexingles.html redirects => mysite.com/en
 * Summarizing
 * Every URL that has mysite.com/non-existen-page redirects to the main page: mysite.
   com/es/. Its a very bad thing that it doesn’t get a 404 error. I have to change
   this and I don’t know how .
 * If the URL is mysite.com/es/non-existen-page it gets a 404 error which is ok.
 * If the URL is mysite.com/en/non-existen-page it gets a 404 error which is ok.
 * Thanks in advance
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fmultisite-redirect-issue%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/#post-13993779)
 * The idea is any request to the main domain should be redirected to /es/, right?
   If it’s a bad request, it should then 404 in the /es/ site. For that to work,
   the bad request has to be passed to /es/. Try replacing the first RewriteRule
   line with this:
    `RewriteRule (.*) https://mysite.com/es/$1 [R=301,L]`
 * (you only need to escape special chars in regexps. The destination URL is not
   a regexp)
 *  Thread Starter [Irene](https://wordpress.org/support/users/arlinaite/)
 * (@arlinaite)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/#post-13993845)
 * Ok thanks! I will try this when I have low traffic and I will come back with 
   the answer.
 *  Thread Starter [Irene](https://wordpress.org/support/users/arlinaite/)
 * (@arlinaite)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/#post-13994870)
 * Sorry but the code provided cause an error of too many redirects
    -  This reply was modified 5 years, 4 months ago by [Irene](https://wordpress.org/support/users/arlinaite/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/#post-13998977)
 * Ah, sorry about that. We need another RewriteCond to not rewrite if it has already
   been rewritten. After `RewriteEngine On`, insert:
    `RewriteCond %{REQUEST_URI}!
   ^/es/`
 * Do you have other domains or sub-domains landing in the same directory? If not,
   I’d think
 *     ```
       RewriteCond %{HTTP_HOST} ^mysite\.com$ [OR]
       RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
       ```
   
 * would be unnecessary since it’d always be one or the other. But then, “If it 
   ain’t broke, don’t fix it” 🙂
 *  Thread Starter [Irene](https://wordpress.org/support/users/arlinaite/)
 * (@arlinaite)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/#post-13999562)
 * Ok, thanks!!! I deleted some code that was before, I applied the changes and 
   it worked.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Multisite redirect issue’ is closed to new replies.

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 5 replies
 * 2 participants
 * Last reply from: [Irene](https://wordpress.org/support/users/arlinaite/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/multisite-redirect-issue/#post-13999562)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
