[英]htaccess 301 redirect with WordPress and subdomains
Basically I am trying to redirect a few of my subdomains, and all of the pages in that sub directory, to the root directory now that I have my site updated. 基本上,由于我已更新站点,因此我试图将我的几个子域以及该子目录中的所有页面重定向到根目录。 So it would go something like this:
所以它会像这样:
usa.example.com --> example.com
can.example.com --> example.com
th.example.com --> example.com
This is what I was suggested to use but no luck: 建议我使用此方法,但没有运气:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
# BEGIN WordPress and SEO Rewrites
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST}^australia|canada|china)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress and SEO Rewrites
RewriteCond %{HTTP_HOST} ^(australia|canada|china)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
OR, if the subdomains are the first ones you mentioned, then 或者,如果子域是您提到的第一个子域,则
RewriteCond %{HTTP_HOST} ^(usa|can|th)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.