The method is as follows:
1. Create a new .htaccess file in the directory where you need to use the .htaccess file, such as my Discuz forum directory:
Vim /var/www/html/168pc/bbs/.htaccess
2. Enter the rules in it, here I enter the pseudo-static rules of Discuz:
# nginx rewrite rulerewrite ^(.* )/archiver/((fid|
Tid)-[w-]+.html)$ $1/archiver/index.php?$2 last;rewrite ^(.*)/forum-([0-9]+)-([0-9]+). Html$ $1/forumdisplay.php?fid=$2&page=$3 last;rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9 ]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;rewrite ^(.*)/profile-(username|
Uid)-(.+).html$ $1/viewpro.php?$2=$3 last;rewrite ^(.*)/space-(username|
Uid)-(.+).html$ $1/space.php?$2=$3 last;rewrite ^(.*)/tag-(.+).html$ $1/tag.php?name=$2 last;# end Nginx rewrite rule
wq save and exit.
3. Modify the nginx configuration file:
vim /etc/nginx/nginx.conf
4. Introduced in the server{} where you need to add a pseudo-static virtual host The .htaccess file, as shown:
include /var/www/html/168pc/bbs/.htaccess;(change this to the specific location of your .htaccess file) Br>
wq save and exit.
5. Reload the nginx configuration file:
/etc/init.d/nginx reload
Reopen the webpage and see if your pseudo-static is normal. The rule syntax is correct. Normal, finished!
Supplement: I found on the Internet that I can automatically convert Apache Rewrite pseudo-static rules to Nginx Rewrite pages online. You can give it a try.
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
The contents of this address contain functions that can be modified as described above. It is to automatically convert the rules in .htaccess to the rules available under nginx.
Summary: The .htaccess file is originally a Apache-specific distributed configuration file that provides a way to change the configuration for each directory, that is, to place a file containing instructions in a specific directory. This directory and all its subdirectories. In fact, modify it, nginx can also use .htaccess file to achieve a variety of functions. Implementing pseudo-static is just one of the uses of .htaccess. .htaccess can also do a lot of purposes, such as filtering access IP, setting web directory access rights, passwords, and so on.
First, the environment: vmware workstaion 9.0centos 6.2iou-web Second, installation 1. Installation
1. In STM32, there are five clock sources, HSI, HSE, LSI, LSE, PLL. 1, HSI is a high-speed internal
CentOS modify IP address First turn off the firewall: service iptables stop# ifconfig eth0 192.168.1
As the demand for PaaS and DevOps solutions grows, we can see that legacy applications running on v
How to hide PHP version in Linux server
Ssh certificate authentication landing implementation tutorial
How to remove the old kernel of Ubuntu Linux system
Usage shell background regular tasks of
Linux file permissions learning
Linux environment programming - waitpid with fork and execlp
Getting Started with AT&T Syntax under Linux (GNU as Assembly Syntax)
Analysis of the application of Linux system in DVR equipment
How to clear the power plan created by Windows7?
Windows slowdown Cause analysis and solution
How to solve the wauuclt.exe error message in Win8.1 system?
Win10 first anniversary update official version how to install
View IP address method (public address and private address) under Win8 system
How to uninstall Baidu browser Baidu browser uninstall tutorial
What should I do if the open mode option in the right-click menu of winXP computer is gone?