我想将子域名中的所有帖子重定向到实时域名。
例如,www.blog.mydomain1.com/post-1到www.mydomain1.com/post-1
我试试这个htaccess代码,它重定向主子域名,但它没有重定向帖子链接
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.mydomain1\.com$ [NC]
RewriteRule ^(.*) http://www.mydomain1.com/$1 [R=301,L]
我的完整HTAccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [NC,R,L]
# BEGIN MainWP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/plugins/mainwp-child/(.*)$ /wp-content/plugins/THIS_PLUGIN_DOES_NOT_EXIST [QSA,L]
</IfModule>
# END MainWP
答案 0 :(得分:0)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [NC,R,L]
在测试此重定向之前清除浏览器缓存。