파일이 존재하는데도 Apache RewriteCond가 "REQUEST_FILENAME"과 일치하지 않습니까?

파일이 존재하는데도 Apache RewriteCond가 "REQUEST_FILENAME"과 일치하지 않습니까?

추적 로그:

apache_1    | [Wed Nov 20 17:14:43.950796 2019] [rewrite:trace2] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] init rewrite engine with requested uri /css/main.css
apache_1    | [Wed Nov 20 17:14:43.950822 2019] [rewrite:trace3] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] applying pattern '^' to uri '/css/main.css'
apache_1    | [Wed Nov 20 17:14:43.950836 2019] [rewrite:trace4] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] RewriteCond: input='/css/main.css' pattern='-f' => not-matched
apache_1    | [Wed Nov 20 17:14:43.950839 2019] [rewrite:trace3] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] applying pattern '^' to uri '/css/main.css'
apache_1    | [Wed Nov 20 17:14:43.950842 2019] [rewrite:trace2] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] rewrite '/css/main.css' -> '/index.php'
apache_1    | [Wed Nov 20 17:14:43.950845 2019] [rewrite:trace2] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] local path result: /index.php
apache_1    | [Wed Nov 20 17:14:43.950850 2019] [rewrite:trace2] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] prefixed with document_root to /var/www/html/public/index.php
apache_1    | [Wed Nov 20 17:14:43.950852 2019] [rewrite:trace1] [pid 9:tid 140252198749952] mod_rewrite.c(483): [client 172.18.0.1:54078] 172.18.0.1 - - [localhost/sid#7f8f031725e8][rid#7f8f0078a0a0/initial] go-ahead with /var/www/html/public/index.php [OK]

중요한 것은:

RewriteCond: input='/css/main.css' pattern='-f' => not-matched

왜 파일을 찾을 수 없나요? 확실히 거기 있어요.

구성은 다음과 같습니다.

    DocumentRoot /var/www/html/public/

파일은 다음 위치에 있습니다 /var/www/html/public/css/main.css.


아파치에서 실행하면 strace다음이 표시됩니다.

apache_1    | [pid    11] poll([{fd=9, events=POLLIN}], 1, 3000 <unfinished ...>
apache_1    | [pid    10] <... select resumed> )      = 0 (Timeout)
apache_1    | [pid    10] wait4(-1, 0x7ffd156f4e0c, WNOHANG|WSTOPPED, NULL) = 0
apache_1    | [pid    10] times({tms_utime=2, tms_stime=13, tms_cutime=0, tms_cstime=0}) = 478112492
apache_1    | [pid    10] select(0, NULL, NULL, NULL, {tv_sec=1, tv_usec=0}) = 0 (Timeout)
apache_1    | [pid    10] wait4(-1, 0x7ffd156f4e0c, WNOHANG|WSTOPPED, NULL) = 0
apache_1    | [pid    10] times({tms_utime=2, tms_stime=13, tms_cutime=0, tms_cstime=0}) = 478112592
apache_1    | [pid    10] select(0, NULL, NULL, NULL, {tv_sec=1, tv_usec=0}) = 0 (Timeout)
apache_1    | [pid    10] wait4(-1, 0x7ffd156f4e0c, WNOHANG|WSTOPPED, NULL) = 0
apache_1    | [pid    10] times({tms_utime=2, tms_stime=13, tms_cutime=0, tms_cstime=0}) = 478112692
apache_1    | [pid    10] select(0, NULL, NULL, NULL, {tv_sec=1, tv_usec=0} <unfinished ...>
apache_1    | [pid    67] <... epoll_wait resumed> [{EPOLLIN, {u32=3893182512, u64=140578172780592}}], 52, -1) = 1
apache_1    | [pid    59] <... epoll_wait resumed> [{EPOLLIN, {u32=3893182512, u64=140578172780592}}], 52, -1) = 1
apache_1    | [pid    67] accept4(3,  <unfinished ...>
apache_1    | [pid    59] accept4(3,  <unfinished ...>
apache_1    | [pid    67] <... accept4 resumed> {sa_family=AF_INET, sin_port=htons(42176), sin_addr=inet_addr("172.18.0.1")}, [128->16], SOCK_CLOEXEC) = 16
apache_1    | [pid    59] <... accept4 resumed> 0x7fda85ffad30, [128], SOCK_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
apache_1    | [pid    67] futex(0x7fdae80d3160, FUTEX_WAKE_PRIVATE, 1) = 1
apache_1    | [pid    59] epoll_wait(13,  <unfinished ...>
apache_1    | [pid    67] epoll_wait(13,  <unfinished ...>
apache_1    | [pid    22] <... futex resumed> )       = 0
apache_1    | [pid    22] futex(0x7fdae80d30e8, FUTEX_WAKE_PRIVATE, 1) = 0
apache_1    | [pid    22] getsockname(16, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("172.18.0.3")}, [128->16]) = 0
apache_1    | [pid    22] fcntl(16, F_GETFL)          = 0x2 (flags O_RDWR)
php-main_1  | - -  20/Nov/2019:17:40:08 +0000 "GET /css/main.css" 200
apache_1    | [pid    22] fcntl(16, F_SETFL, O_RDWR|O_NONBLOCK) = 0
apache_1    | [pid    22] read(16, "GET /css/main.css HTTP/1.1\r\nHost"..., 8000) = 90
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] write(6, "[Wed Nov 20 17:40:08.966703 2019"..., 249[Wed Nov 20 17:40:08.966703 2019] [rewrite:trace2] [pid 13:tid 140578125055744] mod_rewrite.c(483): [client 172.18.0.1:42176] 172.18.0.1 - - [localhost/sid#7fdae7cfe5e8][rid#7fdae43100a0/initial] init rewrite engine with requested uri /css/main.css
apache_1    | ) = 249
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] write(6, "[Wed Nov 20 17:40:08.966779 2019"..., 240[Wed Nov 20 17:40:08.966779 2019] [rewrite:trace3] [pid 13:tid 140578125055744] mod_rewrite.c(483): [client 172.18.0.1:42176] 172.18.0.1 - - [localhost/sid#7fdae7cfe5e8][rid#7fdae43100a0/initial] applying pattern '^' to uri '/css/main.css'
apache_1    | ) = 240
apache_1    | [pid    22] stat("/css/main.css", 0x7fdae534f8d0) = -1 ENOENT (No such file or directory)
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] write(6, "[Wed Nov 20 17:40:08.966875 2019"..., 259[Wed Nov 20 17:40:08.966875 2019] [rewrite:trace4] [pid 13:tid 140578125055744] mod_rewrite.c(483): [client 172.18.0.1:42176] 172.18.0.1 - - [localhost/sid#7fdae7cfe5e8][rid#7fdae43100a0/initial] RewriteCond: input='/css/main.css' pattern='-f' => not-matched
apache_1    | ) = 259
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] write(6, "[Wed Nov 20 17:40:08.966925 2019"..., 240[Wed Nov 20 17:40:08.966925 2019] [rewrite:trace3] [pid 13:tid 140578125055744] mod_rewrite.c(483): [client 172.18.0.1:42176] 172.18.0.1 - - [localhost/sid#7fdae7cfe5e8][rid#7fdae43100a0/initial] applying pattern '^' to uri '/css/main.css'
apache_1    | ) = 240
apache_1    | [pid    22] getpid()                    = 13
apache_1    | [pid    22] write(6, "[Wed Nov 20 17:40:08.966980 2019"..., 236[Wed Nov 20 17:40:08.966980 2019] [rewrite:trace2] [pid 13:tid 140578125055744] mod_rewrite.c(483): [client 172.18.0.1:42176] 172.18.0.1 - - [localhost/sid#7fdae7cfe5e8][rid#7fdae43100a0/initial] rewrite '/css/main.css' -> '/index.php'

편집하다

Apache가 왜 읽으려고 합니까 /css/main.css? 거기에서 문서 루트를 사용하지 않는 이유는 무엇입니까?

답변1

https://serverfault.com/questions/78125/mod-rewrite-request-filename-doesnt-contain-absolute-path

REQUEST_FILENAMEApaChe ConFig ORRRR에 있는지에 따라 다른 값을 반환하는 것 같은데 .htaccess...

관련 정보