开发者

Wordpress tags redirect to subdomains

I've a Wordpress blog and I'd like to redirect some tags to a subdomain. I've created the subdomain in the admin panel of开发者_JAVA技巧 my host.

Example: http://www.myblog.com/tag/numberone http://numberone.myblog.com

I've tried with this code but it doesn't work:

RewriteCond %{REQUEST_URI} ^tag/numberone
RewriteRule ^tag/numberone/(.*)$ http://numberone.myblog.com/$1 [R]

I've also tried the Wp-Subdomains plugin but it doesn't work with Wordpress 3.x


You could take advantage of the Wordpress Template Hierarchy to link to the subdomain.

Create a file called tag-numberone.php and place it inside the theme directory.

Inside this file put the following code:

<?php wp_redirect('http://numberone.myblog.com', 301); exit; ?>

This code will use the wordpress function wp_redirect to direct you to the subdomain you require and also add in the HTTP redirect status (301 for permanent redirects, 302 for temporary).

This should do the trick. You can also create a file for each tag you want to redirect with by using the slug of the tag in the filename: tag-tag1_slug.php, tag-tag2_slug.php, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜