The MU forums have moved to WordPress.org

Switching domains using htaccess (2 posts)

  1. DarkPepe
    Member
    Posted 17 years ago #

    Hi, I've just recently switch my domain name from blog.com to blog.net (example).

    There is a way of bulding a rewrite rule to make a redirection using the user input url? I'll explain myself:

    I want to be able to redirect users that type myblog.blog.com to myblog.blog.net

    Also, if the user has typed something like http://myblog.blog.com/examplepage/ the redirection takes him to http://myblog.blog.net/examplepage/

    ?? I'm trying to understand the documentation of mod_rewrite but is too complicated for me.

    Can anybody give me a little help?

    Thank You Guys.

  2. lunabyte
    Member
    Posted 17 years ago #

    Are you 100% sure you want to do that?
    I'm not sure if your MU install is up and running or not, but that is going to affect every user you have.

    Not to mention, for each user you'll have to modify their options table and whatnot to change every instance of domain.com to domain.net.

    This should work, but no guarantees. ;)


    RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC]
    RewriteRule ^(.*)$ http://yourdomain.net/$1 [R=301,L]

    It's essentially the same for kicking people off of the www subdomain and redirecting them.

    Put that in your htaccess file after the www rewrite rule.

About this Topic

  • Started 17 years ago by DarkPepe
  • Latest reply from lunabyte