mod_rewrite 配置问题
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [L] // 之前在 index.php 后面追加问号,但是那样就不是 path_info 模式了 ?
.htaccess 中如下配置重写没有成功
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /web/restful/index.php/$1 [L]
apache LogLevel
LogLevel alert rewrite:trace3 // 运行 tail -f error_log|fgrep '[rewrite:' // 捕获到的如下提示:
[vagrant@localhost logs]$ tail -f error_log|fgrep '[rewrite:' [Tue Apr 11 08:51:27.852386 2017] [rewrite:trace1] [pid 14418:tid 140420398905088] mod_rewrite.c(477): [client 192.168.33.1:55502] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb624006918/initial/redir#1] [perdir /web/restful/] pass through /web/restful/index.php [Tue Apr 11 08:51:33.041477 2017] [rewrite:trace3] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb62400aa10/initial] [perdir /web/restful/] strip per-dir prefix: /web/restful/article -> article [Tue Apr 11 08:51:33.041513 2017] [rewrite:trace3] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb62400aa10/initial] [perdir /web/restful/] applying pattern '^(.*)$' to uri 'article' [Tue Apr 11 08:51:33.041532 2017] [rewrite:trace2] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb62400aa10/initial] [perdir /web/restful/] rewrite 'article' -> '/web/restful/index.php/article' [Tue Apr 11 08:51:33.041540 2017] [rewrite:trace2] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb62400aa10/initial] [perdir /web/restful/] strip document_root prefix: /web/restful/index.php/article -> /restful/index.php/article [Tue Apr 11 08:51:33.041544 2017] [rewrite:trace1] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb62400aa10/initial] [perdir /web/restful/] internal redirect with /restful/index.php/article [INTERNAL REDIRECT] [Tue Apr 11 08:51:33.041585 2017] [rewrite:trace3] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb6240119c8/initial/redir#1] [perdir /web/restful/] add path info postfix: /web/restful/index.php -> /web/restful/index.php/article [Tue Apr 11 08:51:33.041592 2017] [rewrite:trace3] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb6240119c8/initial/redir#1] [perdir /web/restful/] strip per-dir prefix: /web/restful/index.php/article -> index.php/article [Tue Apr 11 08:51:33.041597 2017] [rewrite:trace3] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb6240119c8/initial/redir#1] [perdir /web/restful/] applying pattern '^(.*)$' to uri 'index.php/article' [Tue Apr 11 08:51:33.041608 2017] [rewrite:trace1] [pid 14419:tid 140420524795648] mod_rewrite.c(477): [client 192.168.33.1:55688] 192.168.33.1 - - [api.com/sid#25c1bb8][rid#7fb6240119c8/initial/redir#1] [perdir /web/restful/] pass through /web/restful/index.php