301 redirection Method for WordPress Domain Name Change (Classic)

Source: Internet
Author: User
Tags wordpress domain
ArticleDirectory
    • 2. For Windows hosts, you can use PHP to jump (the method is from the Internet)

1. Linux host, which is the simplest. Modify. htaccess

Modify the WordPress Part Of The. htaccess file as follows:

 
#Begin WordPress<Ifmodule mod_rewrite.c>Options+Followsymlinksrewriteengine onrewritecond% {Http_host} ^ www. Old.COM [Nc] rewriterule^ (. *) $ Http://Www.new.com/#1 [L, r = 301]</Ifmodule>#End WordPress

Note: www.old.com is replaced with your old domain name, And www.new.com is replaced with your new domain name.

2. For Windows hosts, you can use PHP to jump (the method is from the Internet)

modify the wp-blog-header.php under the WordPress root directory and start with the file Code to PHP:

  If  ( strtolower  ($ _ server  ['server _ name'])! = 'Abc. com ') {  $ uriredirect  = $ _ server  ['request _ url' ];   If  ( strtolower  ( $ uriredirect ) ="/index. PHP ") {  $ uriredirect  ="/";}  header  ('HTTP/1.1 301 moved permanently ' );   header  ('location: http://abc.com '.  $ uriredirect   );   exit   ();}  

Note: Change the two abc.com to your new domain name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.