- 我想要网址:
http://api.relaunch.local/rest/v1/akb/
- 重写为:
http://api.relaunch.local/?id=1873&eID=dispatch&controller=akb
akb
变量部分在哪里。
我尝试了无数种变化但都没有成功,这是我在 .htaccess 中的最后一次尝试:
RewriteEngine On
RewriteBase /
RewriteRule "^rest/v1/([^/]*)/" "index.php?id=1873&eID=dispatch&controller=$1" [L]
当我使用此测试服务时,此规则有效:https://htaccess.madewithlove.be?share=eef157ef-0b95-58e2-a42d-6312ee710275
但在我的 Apache 上不行。我使用的是 Apache 2.4 和 PHP-FPM 7.1
重写日志:
[Sat Oct 13 19:01:56.394388 2018] [rewrite:trace3] [pid 22532:tid 123145530462208] mod_rewrite.c(482): [client 127.0.0.1:55904] 127.0.0.1 - - [api.relaunch.local/sid#7fff0281a5c8][rid#7fff038892a0/initial] [perdir /Users/bandanh/Sites/relaunch.dev/public/] strip per-dir prefix: /Users/bandanh/Sites/relaunch.dev/public/index.php -> index.php
[Sat Oct 13 19:01:56.395768 2018] [rewrite:trace3] [pid 22532:tid 123145530462208] mod_rewrite.c(482): [client 127.0.0.1:55904] 127.0.0.1 - - [api.relaunch.local/sid#7fff0281a5c8][rid#7fff038892a0/initial] [perdir /Users/bandanh/Sites/relaunch.dev/public/] applying pattern '^rest/v1/([^/]*)/' to uri 'index.php'
[Sat Oct 13 19:01:56.395788 2018] [rewrite:trace1] [pid 22532:tid 123145530462208] mod_rewrite.c(482): [client 127.0.0.1:55904] 127.0.0.1 - - [api.relaunch.local/sid#7fff0281a5c8][rid#7fff038892a0/initial] [perdir /Users/bandanh/Sites/relaunch.dev/public/] pass through /Users/bandanh/Sites/relaunch.dev/public/index.php
虚拟主机:
<Directory /Users/bandanh/Sites/relaunch.local/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html
</Directory>
<IfModule proxy_fcgi_module>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/Users/bandanh/Sites/.vhosts/sockets/php-fpm-71.sock|fcgi://localhost"
</FilesMatch>
</IfModule>
LogLevel alert rewrite:trace3