Apache (PHP server) pseudo static modification. htaccess Implementation 301 redirect

Source: Internet
Author: User
Tags php server

Note: Be sure to back up the. htaccess file in the corresponding directory before you set 301 redirection.

1.301 redirect b.org to www.b.org
This redirect is designed to make the domain name unique, is the website SEO must do, the back redirects www.b.org to b.org is also for the same reason, but the form is different.

Open the. htaccess file and add the following rules. (The following rule is for the primary domain name, and the subdomain is to be modified)

The code is as follows Copy Code

Rewriteengine on

Rewritecond%{http_host}!^www.b.org$ [NC]

Rewriterule ^.$ http://www.b.org/$1 [l,r=301]

2.301 redirect www.b.org to b.org

The code is as follows Copy Code

Rewriteengine on

Rewritecond%{http_host}!^b.org$ [NC]

Rewriterule ^.$ http://b.org/$1 [l,r=301]

3.301 redirect c.com to www.a.com

The code is as follows Copy Code


Rewriteengine on

Rewritecond%{http_host}!c.com$ [NC]

Rewriterule ^.$ http://www.a.com/$1 [l,r=301]

4.301 redirect c.com to A.com

  code is as follows copy code

Rewriteengine On

Rewritebase/rewritecond%{http_host}!c.com$ [NC]

Rewriterule ^.$ http://a.com/$1 [l,r=301]

5.3 01 redirect domain.com/file/file.php to oo.com/otherfile/other.php


Rewritecond%{http_host} ^www.domain.com$

Rewriterule ^file/file.php$ http://www.oo.com/otherfile/other.php [r=301,l]

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.