My site structure is main site example.com
and two subfolders sites /es/
and /en/
example.com
redirects => example.com/es/
and example.com/en/
is the English version.
What is wrong?
The following:
example.com/<non-existing-page>
redirects => example.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 example.com/es/
instead of getting a 404 error. I see where is the problem but I don't know how to modify the rule.
My redirect in the .htaccess
file:
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
RewriteCond %{ENV:REDIRECT_STATUS} ^$
# Main Redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "https\:\/\/example\.com\/es\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^index\.html$ "https\:\/\/example\.com\/es\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^indexingles\.html$ "https\:\/\/example\.com\/en\/" [R=301,L]
Works perfect for the following:
- Is perfect that
example.com/index.php
redirects =>example.com/es
- Is perfect that
index.html
redirects =>example.com/es
- Is perfect that
indexingles.html
redirects =>example.com/en
Summarizing
Every URL that has example.com/<non-existent-page>
redirects to the main page: example.com/es/
.
It's wrong that a non-existent-page doesn't get a 404 error. I have to change this and I don't know how.
If the URL is example.com/es/<non-existent-page>
it gets a 404 error which is OK.
If the URL is example.com/en/<non-existent-page>
it gets a 404 error which is OK.
Note:
If somebody else is going to use this redirect, I want to add that Mr. White redirection is working just fine. However order to make the redirection of the backend to work properly I had to delete Wordfence plugin.
example.com
?