好的,这就是我得到的......
如果我使用http://192.168.1.209/restAPI/player/read则会失败并显示错误"在此服务器上找不到请求的URL / restAPI /播放器/读取。"
[Thu Dec 14 16:24:54.572442 2017] [rewrite:trace3] [pid 960] mod_rewrite.c(476): [client 192.168.1.33:56408] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b5390a0/subreq] [perdir /var/www/html/restAPI/] strip per-dir prefix: /var/www/html/restAPI/player/read.php -> player/read.php
[Thu Dec 14 16:24:54.572490 2017] [rewrite:trace3] [pid 960] mod_rewrite.c(476): [client 192.168.1.33:56408] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b5390a0/subreq] [perdir /var/www/html/restAPI/] applying pattern '^(.*)$' to uri 'player/read.php'
[Thu Dec 14 16:24:54.572503 2017] [rewrite:trace4] [pid 960] mod_rewrite.c(476): [client 192.168.1.33:56408] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b5390a0/subreq] [perdir /var/www/html/restAPI/] RewriteCond: input='/var/www/html/restAPI/player/read.php' pattern='!-f' => not-matched
[Thu Dec 14 16:24:54.572508 2017] [rewrite:trace1] [pid 960] mod_rewrite.c(476): [client 192.168.1.33:56408] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b5390a0/subreq] [perdir /var/www/html/restAPI/] pass through /var/www/html/restAPI/player/read.php
如果我使用http://192.168.1.209/restAPI/index.php/player/read则可行 以下是相关日志
info postfix: /var/www/html/restAPI/index.php -> /var/www/html/restAPI/index.php/player/read
[Thu Dec 14 16:27:29.872076 2017] [rewrite:trace3] [pid 963] mod_rewrite.c(476): [client 192.168.1.33:56440] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b54f0a0/initial] [perdir /var/www/html/restAPI/] strip per-dir prefix: /var/www/html/restAPI/index.php/player/read -> index.php/player/read
[Thu Dec 14 16:27:29.872087 2017] [rewrite:trace3] [pid 963] mod_rewrite.c(476): [client 192.168.1.33:56440] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b54f0a0/initial] [perdir /var/www/html/restAPI/] applying pattern '^(.*)$' to uri 'index.php/player/read'
[Thu Dec 14 16:27:29.872102 2017] [rewrite:trace4] [pid 963] mod_rewrite.c(476): [client 192.168.1.33:56440] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b54f0a0/initial] [perdir /var/www/html/restAPI/] RewriteCond: input='/var/www/html/restAPI/index.php' pattern='!-f' => not-matched
[Thu Dec 14 16:27:29.872108 2017] [rewrite:trace1] [pid 963] mod_rewrite.c(476): [client 192.168.1.33:56440] 192.168.1.33 - -
[192.168.1.209/sid#7f089b61b808][rid#7f089b54f0a0/initial] [perdir /var/www/html/restAPI/] pass through /var/www/html/restAPI/index.php
为了使它更有趣,我的函数将调用的实际文件是/player/read.php 此外,如果我在/ player目录中调用没有文件的http://192.168.1.209/restAPI/player/update,它也能正常工作 这是我在/ restAPI目录中的httaccess文件内容
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]