Nginx rewrite and redirect module usage instructions

Source: Internet
Author: User
Keywords Nginx redirect
Tags aliyun apache basic continue directory file html http

Nginx Rewrite

1. Nginx Rewrite basic mark (Flags)

Last-basically use this flag.
※ equivalent to http://www.aliyun.com/zixun/aggregation/14417.html ">apache [L] tag, indicating completion of rewrite, no longer match the following rules

Break-Abort Rewirte, no longer match

Redirect-returns the temporarily redirected HTTP status 302

Permanent-Returns the HTTP status of a permanent redirect 301※ the URL that supports regular overrides does not support regular

2. Regular expression matching, where:

* To match case sensitivity

* ~* matching for case-insensitive

*!~ and!~* are case insensitive and case-insensitive mismatches, respectively

3. File and directory matching, where:

*-F and!-f are used to determine whether a file exists

*-D and!-d used to determine whether a directory exists

*-E and!-e used to determine whether a file or directory exists

*-X and!-x are used to determine whether a file is executable

3. Some of the global variables available in Nginx can be judged by condition:

$args
$content _length
$content _type
$document _root
$document _uri
$host
$http _user_agent
$http _cookie
$limit _rate
$request _body_file
$request _method
$remote _addr
$remote _port
$remote _user
$request _filename
$request _uri
$query _string
$scheme
$server _protocol
$server _addr
$server _name
$server _port
$uri

Nginx Redirect

All ithov.com and netseek.ithov.com domain names from the jump to http://www.ithov.com

Server
{
Listen 80;
server_name ithov.com netseek.ithov.com;
Index index.html index.php;
Root/data/www/wwwroot;
if ($host!~ "^www\.linxtone\.org$") {
Rewrite ^ (. *) http://www.ithov.com$1 redirect;
}
........................
}

Related Article

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.