我的网站结构是主网站example.com
和两个子文件夹站点/es/
和/en/
example.com
重定向=>;example.com/es/
和example.com/en/
是英文版。
怎么了?
以下内容:
example.com/<non-existing-page>
重定向=>;example.com/es/
这个主重定向的某些部分导致mysite中的每个不存在的页面。com(此站点为空)被重定向到子域中的主页example.com/es/
而不是得到404错误。我知道问题出在哪里,但我不知道如何修改规则。
中的我的重定向.htaccess
文件:
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]
适用于以下方面:这是完美的example.com/index.php
重定向=>;example.com/es
index.html 重定向=>;example.com/es
indexingles.html 重定向=>;example.com/en
总结
每个具有example.com/<non-existent-page>
重定向到主页:example.com/es/
.
一个不存在的页面没有得到404错误是错误的。我必须改变这个,我不知道怎么做。
如果URL为example.com/es/<non-existent-page>
它得到一个404错误,这是正常的。
如果URL为example.com/en/<non-existent-page>
它得到一个404错误,这是正常的。
Note:
如果其他人要使用此重定向,我想补充一点,怀特先生的重定向工作得很好。然而,为了使后端重定向正常工作,我不得不删除Wordfence插件。