Believe that the person familiar with Web server must be familiar with APAHCE. Believe that the person familiar with Apahce must know the URL Rewrite. Apache's Mod_rewrite module can help people construct a variety of landscaping URLs. There are several ways to use URL Rewrite in Apache: One is to add the appropriate rewriterule (rewrite rules) directly to the httpd.conf, and the other is to add rewriterule (rewrite rules) to. htaccess in the root directory of the Web site. However, it is important to note that the two files added to the URL rewrite rules are slightly different. These differences, for unfamiliar people, are likely to be troubled for a long time.
In the httpd.conf:
(1) The beginning of the Request URI must begin with a slash;
(2) When looking for the cache file, you must add a slash at the beginning;
(3) When using-F or!-f, you must add a slash at the beginning.
In. htaccess, the exact opposite is the case:
(1) The Request URI must not have a slash at the beginning;
(2) When looking for the cache file, do not add a slash at the beginning;
(3) When using-F or!-f, you cannot add a slash at the beginning.
Simply put, in httpd.conf, the URL before and after the rewrite needs to be preceded by a slash "/" when using an absolute path, which means that it starts at the root of the Web site and is not required in. htaccess. Here are two simple examples:
httpd.conf
Rewriterule ^/$/cache/index.html [QSA]
Rewriterule ^/([^.] +) $/cache/$1.html [QSA]
Rewritecond%{document_root}%{request_filename}!-f
Rewriterule ^ (. *) $ dispatch.fcgi [qsa,l]
. htaccess
Rewriterule ^$ cache/index.html [QSA]
Rewriterule ^ ([^.] +) $ cache/$1.html [QSA]
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ dispatch.fcgi [qsa,l]
Perhaps there are more differences, we can also focus on their own research.
For example, one written in the. htaccess.
<ifmodule mod_rewrite.c>#禁止 All Access ....<files ~"^. (htaccess|htpasswd|info.php| (\s) +.md| (\s) +.sql) $">Deny from All</Files># Disable access to Vendor ....<Location/vendor>Deny from All</Location>Options+followsymlinks rewriteengine on Rewritecond%{request_filename}!-D Rewritecond%{request_filename}!-F Rewriterule^ (. *) $ index.php?/$1[Qsa,pt,l]</IfModule>
and written in the httpd.conf.
#ThinkPhp Security Configuration ...<ifmodule mod_rewrite.c>#禁止 All Access ....<files ~"^. (htaccess|htpasswd|info.php| (\s) +.md| (\s) +.sql) $">Deny from All</Files># Disable access to vendor .... composer directory where ...<Location/vendor>Deny from All</Location> <Location/ThinkPhp>Deny from All</Location>Options+followsymlinks rewriteengine on Rewritecond%{document_root}%{request_filename}!-D Rewritecond%{document_root}%{request_filename}!-F Rewriterule^/(. *) $ index.php?/$1[Qsa,pt,l]</IfModule>
Apache in htaccess forbidden Access and Conf in the forbidden Difference