沉冰浮水

沉冰浮水

做最终到的事,成为最终成为的人!
github
bilibili
mastodon
zhihu
douban

"Notes". Overview of available variables in .htaccess and nginx.conf.

Even though my search ability is not low, I still struggle to quickly find many things.

.htaccessnginx.confDescription
%{REQUEST_SCHEME}$schemehttp /https
%{HTTP_HOST}$hostdomain / ip
%{REQUEST_URI}$request_uripart after host/
%{REQUEST_FILENAME}$request_filenameseems to be the same as uri
%{QUERY_STRING}$argsquery string (part after ?)
%{HTTP_USER_AGENT}$http_user_agentclient UA
%{REMOTE_ADDR}$remote_addrvisitor'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:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.