我有以下.htaccess 内容:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
RewriteRule ^([0-9a-zA-Z_/]+)?$ index.php?vars=$1 [NC,L,QSA]
我的问题很简单,但我不明白为什么会发生这种情况:
- 当我访问文件时,它可以正常工作
- 当我浏览该网站时,它运行正常
- 当我尝试访问受 .htaccess 保护的文件夹时,它可以正常工作
- 当我尝试访问公共文件夹时,它会重写 URL(第一个条件是“不是文件夹”)
有人知道为什么吗?
编辑:重写日志
[Thu Apr 28 12:57:11.245583 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/images/ -> images/
[Thu Apr 28 12:57:11.245648 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] applying pattern '^(.+[^/])$' to uri 'images/'
[Thu Apr 28 12:57:11.245684 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/images/ -> images/
[Thu Apr 28 12:57:11.245713 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] applying pattern '^([0-9a-zA-Z_/]+)?$' to uri 'images/'
[Thu Apr 28 12:57:11.245743 2016] [rewrite:trace2] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] rewrite 'images/' -> 'index.php?vars=images/'
[Thu Apr 28 12:57:11.245778 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] split uri=index.php?vars=images/ -> uri=index.php, args=vars=images/
[Thu Apr 28 12:57:11.245802 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] add per-dir prefix: index.php -> /var/www/free/index.php
[Thu Apr 28 12:57:11.245832 2016] [rewrite:trace2] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] strip document_root prefix: /var/www/free/index.php -> /index.php
[Thu Apr 28 12:57:11.245857 2016] [rewrite:trace1] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5b0a0/initial] [perdir /var/www/free/] internal redirect with /index.php [INTERNAL REDIRECT]
[Thu Apr 28 12:57:11.246005 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/index.php -> index.php
[Thu Apr 28 12:57:11.246083 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] applying pattern '^(.+[^/])$' to uri 'index.php'
[Thu Apr 28 12:57:11.246123 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/index.php' pattern='!-d' => matched
[Thu Apr 28 12:57:11.246155 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/index.php' pattern='!-f' => matched
[Thu Apr 28 12:57:11.246191 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/index.php' pattern='!-l' => matched
[Thu Apr 28 12:57:11.246223 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] RewriteCond: input='/index.php' pattern='/+[^\\.]+$' => not-matched
[Thu Apr 28 12:57:11.246255 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/index.php -> index.php
[Thu Apr 28 12:57:11.246279 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] applying pattern '^([0-9a-zA-Z_/]+)?$' to uri 'index.php'
[Thu Apr 28 12:57:11.246306 2016] [rewrite:trace1] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf5e050/initial/redir#1] [perdir /var/www/free/] pass through /var/www/free/index.php
[Thu Apr 28 12:57:11.422724 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/images/404.gif -> images/404.gif, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.422861 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] applying pattern '^(.+[^/])$' to uri 'images/404.gif', referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.422939 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/images/404.gif' pattern='!-d' => matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.422997 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/images/404.gif' pattern='!-f' => matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.423057 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/images/404.gif' pattern='!-l' => matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.423227 2016] [rewrite:trace4] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] RewriteCond: input='/images/404.gif' pattern='/+[^\\.]+$' => not-matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.423273 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/images/404.gif -> images/404.gif, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.423301 2016] [rewrite:trace3] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] applying pattern '^([0-9a-zA-Z_/]+)?$' to uri 'images/404.gif', referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.423342 2016] [rewrite:trace1] [pid 4860] mod_rewrite.c(475): [client 37.161.74.115:47510] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3e0a0/initial] [perdir /var/www/free/] pass through /var/www/free/images/404.gif, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635091 2016] [rewrite:trace3] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/images/404.gif -> images/404.gif, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635343 2016] [rewrite:trace3] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] applying pattern '^(.+[^/])$' to uri 'images/404.gif', referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635448 2016] [rewrite:trace4] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/images/404.gif' pattern='!-d' => matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635534 2016] [rewrite:trace4] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/images/404.gif' pattern='!-f' => matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635608 2016] [rewrite:trace4] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] RewriteCond: input='/var/www/free/var/www/free/images/404.gif' pattern='!-l' => matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635692 2016] [rewrite:trace4] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] RewriteCond: input='/images/404.gif' pattern='/+[^\\.]+$' => not-matched, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635751 2016] [rewrite:trace3] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] strip per-dir prefix: /var/www/free/images/404.gif -> images/404.gif, referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635805 2016] [rewrite:trace3] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] applying pattern '^([0-9a-zA-Z_/]+)?$' to uri 'images/404.gif', referer: https://my.website.com/images/
[Thu Apr 28 12:57:11.635947 2016] [rewrite:trace1] [pid 4130] mod_rewrite.c(475): [client 37.161.74.115:47509] 37.161.74.115 - - [my.website.com/sid#7fb7fcff2e38][rid#7fb7fcf3c0a0/initial] [perdir /var/www/free/] pass through /var/www/free/images/404.gif, referer: https://my.website.com/images/