Two methods for redirecting nginx directory 301 to a second-level domain name

Source: Internet
Author: User

For example,/bbs/301 redirects to a new second-level domain name

I directly added a bbs. conf file for lnmp to/usr/local/nginx/conf.

Add an include bbs2.conf entry in the conf configuration of 111cn.net;

Restart completed.

The content of bbs. conf is:

The code is as follows: Copy code

Location ~ * ^/Bbs /{

Rewrite ^/bbs/(. *) $ http: // your second-level domain name/$1 permanent;

}

It should be fine if you do not add this conf file, but you do not know where to insert it. Simply add a conf file to make it simple.

Htaccess file code method

This method is only suitable for apache servers and supports rewrite Pseudo-static. Add the following rule directly to the. htaccess file:

The code is as follows:

The code is as follows: Copy code

RewriteEngine On

RewriteBase/

Redirect permanent/your Directory address http://www.111cn.net/

Rule note: when accessing the original program sub-directory (/your Directory address), the system automatically redirects to your second-level domain name http://bbs.mrlon.net/and another new domain name (please change the domain name URL to your own ).

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.