Even though my search ability is not low, I still struggle to quickly find many things.
.htaccess | nginx.conf | Description |
---|---|---|
%{REQUEST_SCHEME} | $scheme | http /https |
%{HTTP_HOST} | $host | domain / ip |
%{REQUEST_URI} | $request_uri | part after host/ |
%{REQUEST_FILENAME} | $request_filename | seems to be the same as uri |
%{QUERY_STRING} | $args | query string (part after ? ) |
%{HTTP_USER_AGENT} | $http_user_agent | client UA |
%{REMOTE_ADDR} | $remote_addr | visitor's IP |
$scheme://$host/
or%{REQUEST_SCHEME}://%{HTTP_HOST}/
can directly concatenate the current URL.
mod_rewrite Reference_Apache Chinese Documentation:
https://www.apachehttpd.com/mod/mod_rewrite.html
Htaccess - THE Ultimate .htaccess tutorial with 100's of Examples:
https://www.askapache.com/htaccess/#Htaccess_Variables
I. Regular expression matching, where:
~
is for case-sensitive matching;~*
is for case-insensitive matching;!~
and!~*
are for case-sensitive and case-insensitive non-matching, respectively;
II. File and directory matching, where:
-f
and!-f
are used to check if a file exists;-d
and!-d
are used to check if a directory exists;-e
and!-e
are used to check if a file or directory exists;-x
and!-x
are used to check if a file is executable;
III. The last parameter of the rewrite directive is the flag, which can be:
last
initiates a new request for the rewritten URI, the final effect depends on whether the new request can match another rule; "similar to[L]
flag in Apache"break
the current directive specifies the final URI;redirect
returns a 302 temporary redirect, the browser address will display the redirected URL;permanent
returns a 301 permanent redirect, the browser address will display the redirected URL;
In 2022, I just learned that you can't directly use "and" or "or" operations in Nginx configuration?
Nginx implementation to only allow search engines or specified IP addresses to access: