为什么 Apache 的 mod-rewrite 模块处理一些 GET 请求而不处理其他请求?

为什么 Apache 的 mod-rewrite 模块处理一些 GET 请求而不处理其他请求?

我正在尝试让 mod_rewrite 工作。我正在尝试一个非常简单的规则:

RewriteEngine On
RewriteRule ^/one /var/www/html/oldindex.html

这是完整的配置文件:/etc/apache2/sites-available/govmeeting.org.conf

<Directory /var/www/html>
        Require all granted
</Directory>
<VirtualHost *:80>
ServerName govmeeting.org
ServerAlias www.govmeeting.org
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
LogLevel trace6 rewrite_module:trace8
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteRule ^/one /var/www/html/oldindex.html
</VirtualHost>

我从浏览器发送了两个针对“govmeeting.org/one”的请求。 “oldindex.html”存在于我的 DocumentRoot 中。我在 error.log 中看到没有任何处理发生。

然而,大约在同一时间,又有人传来了外部请求。该请求确实得到处理,但不是我的。以下是该时间段的 error.log 和 access.log。请注意,23:05:45 和 23:07:04 的“/one”的 GET 不会被处理。但是 23:07:06 的“//wp-config.php”的 GET 已处理。

我有:服务器版本:Apache/2.4.41(Ubuntu)服务器构建:2021-10-14T16:24:43。服务器在 Google Compute Engine 中的虚拟机上运行。

116.179.32.156 - - [05/Dec/2021:22:41:08 +0000] "GET / HTTP/1.1" 200 8945 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"
67.80.142.21 - - [05/Dec/2021:23:05:45 +0000] "GET /one HTTP/1.1" 404 5729 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
67.80.142.21 - - [05/Dec/2021:23:06:05 +0000] "-" 408 5213 "-" "-"
67.80.142.21 - - [05/Dec/2021:23:07:04 +0000] "GET /one HTTP/1.1" 404 1079 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
136.144.41.231 - - [05/Dec/2021:23:07:06 +0000] "GET //wp-config.php HTTP/1.1" 404 493 "-" "Mozlila/5.0 (Linux; Android 7.0; SM-G892A Bulid/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Moblie Safari/537.36"
67.80.142.21 - - [05/Dec/2021:23:07:24 +0000] "-" 408 563 "-" "-"
209.17.97.34 - - [05/Dec/2021:23:11:47 +0000] "GET / HTTP/1.1" 200 4153 "-" "Mozilla/5.0 (compatible; Nimbostratus-Bot/v1.3.2; http://cloudsystemnetworks.com)"

这是该时间段的 error.log 的部分:

[Sun Dec 05 23:04:26.847532 2021] [mpm_prefork:notice] [pid 17645] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun Dec 05 23:04:26.847605 2021] [core:notice] [pid 17645] AH00094: Command line: '/usr/sbin/apache2'
[Sun Dec 05 23:07:06.213591 2021] [core:trace5] [pid 17650] protocol.c(708): [client 136.144.41.231:35566] Request received from client: GET //wp-config.php HTTP/1.1
[Sun Dec 05 23:07:06.213740 2021] [http:trace4] [pid 17650] http_request.c(436): [client 136.144.41.231:35566] Headers received from client:
[Sun Dec 05 23:07:06.213747 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Host: govmeeting.org
[Sun Dec 05 23:07:06.213751 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   User-Agent: Mozlila/5.0 (Linux; Android 7.0; SM-G892A Bulid/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Moblie Safari/537.36
[Sun Dec 05 23:07:06.213755 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Accept-Encoding: gzip, deflate
[Sun Dec 05 23:07:06.213759 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
[Sun Dec 05 23:07:06.213763 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Connection: keep-alive
[Sun Dec 05 23:07:06.213766 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Cache-Control: max-age=0
[Sun Dec 05 23:07:06.213770 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Upgrade-Insecure-Requests: 1
[Sun Dec 05 23:07:06.213773 2021] [http:trace4] [pid 17650] http_request.c(439): [client 136.144.41.231:35566]   Accept-Language: en-US,en;q=0.9,fr;q=0.8
[Sun Dec 05 23:07:06.213803 2021] [rewrite:trace2] [pid 17650] mod_rewrite.c(483): [client 136.144.41.231:35566] 136.144.41.231 - - [govmeeting.org/sid#7fafa63c3810][rid#7fafa64820a0/initial] init rewrite engine with requested uri /wp-config.php
[Sun Dec 05 23:07:06.213809 2021] [rewrite:trace3] [pid 17650] mod_rewrite.c(483): [client 136.144.41.231:35566] 136.144.41.231 - - [govmeeting.org/sid#7fafa63c3810][rid#7fafa64820a0/initial] applying pattern '^/one' to uri '/wp-config.php'
[Sun Dec 05 23:07:06.213821 2021] [rewrite:trace1] [pid 17650] mod_rewrite.c(483): [client 136.144.41.231:35566] 136.144.41.231 - - [govmeeting.org/sid#7fafa63c3810][rid#7fafa64820a0/initial] pass through /wp-config.php
[Sun Dec 05 23:07:06.213922 2021] [authz_core:debug] [pid 17650] mod_authz_core.c(817): [client 136.144.41.231:35566] AH01626: authorization result of Require all granted: granted
[Sun Dec 05 23:07:06.213929 2021] [authz_core:debug] [pid 17650] mod_authz_core.c(817): [client 136.144.41.231:35566] AH01626: authorization result of <RequireAny>: granted
[Sun Dec 05 23:07:06.213933 2021] [core:trace3] [pid 17650] request.c(310): [client 136.144.41.231:35566] request authorized without authentication by access_checker_ex hook: /wp-config.php
[Sun Dec 05 23:07:06.214003 2021] [php7:error] [pid 17650] [client 136.144.41.231:35566] script '/var/www/html/wp-config.php' not found or unable to stat
[Sun Dec 05 23:07:06.214051 2021] [http:trace3] [pid 17650] http_filters.c(1125): [client 136.144.41.231:35566] Response sent with status 404, headers:
[Sun Dec 05 23:07:06.214070 2021] [http:trace5] [pid 17650] http_filters.c(1134): [client 136.144.41.231:35566]   Date: Sun, 05 Dec 2021 23:07:06 GMT
[Sun Dec 05 23:07:06.214074 2021] [http:trace5] [pid 17650] http_filters.c(1137): [client 136.144.41.231:35566]   Server: Apache/2.4.41 (Ubuntu)
[Sun Dec 05 23:07:06.214077 2021] [http:trace4] [pid 17650] http_filters.c(955): [client 136.144.41.231:35566]   Content-Length: 276
[Sun Dec 05 23:07:06.214084 2021] [http:trace4] [pid 17650] http_filters.c(955): [client 136.144.41.231:35566]   Keep-Alive: timeout=5, max=100
[Sun Dec 05 23:07:06.214087 2021] [http:trace4] [pid 17650] http_filters.c(955): [client 136.144.41.231:35566]   Connection: Keep-Alive
[Sun Dec 05 23:07:06.214090 2021] [http:trace4] [pid 17650] http_filters.c(955): [client 136.144.41.231:35566]   Content-Type: text/html; charset=iso-8859-1
[Sun Dec 05 23:07:06.214111 2021] [core:trace6] [pid 17650] core_filters.c(519): [client 136.144.41.231:35566] will flush because of FLUSH bucket
[Sun Dec 05 23:07:06.313890 2021] [core:trace6] [pid 17650] core_filters.c(519): [client 136.144.41.231:35566] will flush because of FLUSH bucket

相关内容