Nginx pseudo-static configuration and common Rewrite pseudo-static rules, nginxrewrite

Source: Internet
Author: User

Nginx pseudo-static configuration and common Rewrite pseudo-static rules, nginxrewrite

Pseudo-static is a way to change the file suffix to any possible one. If I want to convert the PHP file pseudo-static to an html file, this is quite simple, the following describes the nginx pseudo-static configuration method. For more information, see.

The use of pseudo-static in nginx directly writes rules in nginx. conf, and does not require pseudo-static operations like apache to enable the write module (mod_rewrite.

Nginx only needs to open the nginx. conf configuration file and write the required rules in the server.

Server
{
Listen 80;
Server_name bbs.jb51.net;
Index index.html index.htm index. php;
Root/home/www/bbs;

 

Error_page 404/404 .htm; # configure the 404 error page
Location ~ . *. (Php | php5 )? $
{
# Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fcinclude gi. conf;
}

# Below is the pseudo-static

Location /{
Rewrite ^ (. *)/equip(d00000000.html $1/index. php? M = content & c = index & a = lists & catid = $2 last;
}
Access_log off;
}

Then restart the nginx server and the pseudo-static state will take effect. This maintenance is inconvenient for us to write it in an external file such as bbs_nginx.conf.

Create the bbs_nginx.conf file in the/home/www/bbs directory and write the following code:

Ocation /{
Rewrite ^ (. *)/equip(d00000000.html $1/index. php? M = content & c = index & a = lists & catid = $2 last;
}

Add the following code after the above Code:

Include/home/www/bbs/bbs_nginx.conf;

In this way, the bbs_nginx.conf pseudo-static rules in the root directory of the website can be managed separately.

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.