Google search for information many people say nginx currently do not support the htaccess file, I followed the nginx rules of the test, and found that Nginx is fully supported. htaccess file.
The method is as follows:
1. Create a new. htaccess file in the directory where you need to use the. htaccess file, such as one of my Discuz forum directories:
Vim/var/www/html/168pc/bbs/.htaccess
2. Enter the rules here, I enter the pseudo static rules for Discuz:
# nginx Rewrite rule
rewrite ^ (. *)/archiver/((Fid|tid)-[w-]+.html) $ $1/archiver/index.php?$2;
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 exit.
3. Modify Nginx configuration file:
Vim/etc/nginx/nginx.conf
4. The. htaccess file is introduced in the server{} that requires the addition of pseudo static virtual hosts, as shown in the figure:
Include/var/www/html/168pc/bbs/.htaccess (change this to the exact location of your. htaccess file)
Wq Save exit.
5. Reload the Nginx configuration file:
/etc/init.d/nginx Reload
Reopen the page to see if the pseudo static is normal to prove that your rewrite rule syntax is correct.
Normal, complete.
Add: I found online to automatically convert Apache rewrite pseudo static rules to Nginx rewrite Web pages. We can try.
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
The contents of this address contain the ability to complete the modifications described above. is to automatically convert the rules in. htaccess to the rules available under Nginx.
Summary:. htaccess files are originally Apache-specific distributed configuration files that provide a way to change the configuration for each directory by placing a file containing instructions in a specific directory with instructions for this directory and all of its subdirectories. In fact, Nginx can also use the. htaccess file to implement a variety of functions. Realizing pseudo Static is just one of the uses of. htaccess,. Htaccess can also do many uses, such as filtering access to IP, setting Web Directory access rights, passwords, and so on.