简体   繁体   中英

htaccess Redirect from subdomain to domain

I'm re-working a site and I'm attempting to move a forum from a subdomain (board.example.com) to the primary domain where the path will be example.com/index.php/forums/

I've set up my htaccess file like so:

RewriteEngine On  
RewriteCond %{HTTP_HOST} ^(.*).example.com  
RewriteRule ^(.*)$ http://www.example.com/index.php/forums/ [R=301,L]

which works, but for all of the content that's already been indexed by search engines, the new URLs show up with old references, like

example.com/index.php/forums/?p=1199&sid=4daeb5acf7983a0f8d56737c4812f474

Is there any way to clear up the bit that's getting appended to the end of the new URL?

I'm not sure where your sid parameter is coming from...

The way I would probably try first (before resorting to mod_rewrite) would be:

<VirtualHost *>
  ServerName board.example.com
  Redirect permanent / http://www.example.com/index.php/forums/
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM