Search data on Google many people say Nginx does not support. htaccess file, I followed the nginx rule test, the results found Nginx is fully supported. htaccess file!
Here's how:
1. Create a new. htaccess file in the directory where you want to use the. htaccess file,
As one of my Discuz forum directory:
Vim/var/www/html/168pc/bbs/.htaccess
2. Enter the rules inside and I'll enter the pseudo-static rules for Discuz:
# nginx Rewrite rule
Rewrite ^ (. *)/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 exit.
3. Modify the Nginx configuration file:
Vim/etc/nginx/nginx.conf
4. Introduce the. htaccess file in server{} that requires the addition of pseudo-static virtual hosts:
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
Re-open the Web page and see if pseudo-static normal proves that your rewrite rule syntax is correct.
Normal, finished!
Add: I found on the Internet an Apache rewrite pseudo-static rules can be automatically converted to Nginx rewrite Web page. We can try it.
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
The contents of this address include the ability to complete the above-mentioned minor modifications. is to automatically convert the rules in. htaccess to the rules available under Nginx.
Summary: the. htaccess file was originally a distributed configuration file for Apache, providing a way to change the configuration for each directory, that is, to place a file containing instructions in a particular directory, where the instructions are applied to this directory and all its subdirectories. In fact, to modify the Nginx can also use the. htaccess file for a variety of functions. Implementing pseudo-Static is just one of the purposes of. Htaccess. Htaccess can also do a lot of purposes, such as filtering access to IP, setting Web Directory access permissions, passwords, and so on.
Linux under Nginx Support. htaccess file implementation Pseudo-static Method!