此重写规则未达到目的 :(
RewriteCond %{REQUEST_METHOD} ^(GET)$
RewriteRule ^/wiki-search/(.+)$ NicerAppWebOS/index.php?app-wikipedia.org-search=$1 [L,END,PT,DPI]
apache 日志(在 apache sites-enabled 配置中设置了 rewrite:trace6):
[Tue Aug 29 06:30:46.281647 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] add path info postfix: /var/www/192.168.178.29/wiki-search -> /var/www/192.168.178.29/wiki-search/john
[Tue Aug 29 06:30:46.281648 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] strip per-dir prefix: /var/www/192.168.178.29/wiki-search/john -> wiki-search/john
[Tue Aug 29 06:30:46.281650 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] applying pattern '^/wiki-search/(.+)$' to uri 'wiki-search/john'
[Tue Aug 29 06:30:46.281651 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] add path info postfix: /var/www/192.168.178.29/wiki-search -> /var/www/192.168.178.29/wiki-search/john
[Tue Aug 29 06:30:46.281652 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] strip per-dir prefix: /var/www/192.168.178.29/wiki-search/john -> wiki-search/john
[Tue Aug 29 06:30:46.281654 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] applying pattern '^/wiki-search/(.+)$' to uri 'wiki-search/john'
[Tue Aug 29 06:30:46.281655 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] add path info postfix: /var/www/192.168.178.29/wiki-search -> /var/www/192.168.178.29/wiki-search/john
[Tue Aug 29 06:30:46.281656 2023] [rewrite:trace3] [pid 2760088] mod_rewrite.c(480): [client 192.168.178.29:45136] 192.168.178.29 - - [192.168.178.29/sid#7ff3a4331d20][rid#7ff3a438f0a0/initial] [perdir /var/www/192.168.178.29/] strip per-dir prefix: /var/www/192.168.178.29/wiki-search/john -> wiki-search/john
我在 Ubuntu 22.04 上运行,带有最新的 apache2:
root@parakeet:/var/www/192.168.178.29/NicerAppWebOS/scripts.maintenance# apache2 -v
Server version: Apache/2.4.52 (Ubuntu)
Server built: 2023-05-03T20:02:51
我确实需要一些 mod-rewrite 专家的帮助。
有关该应用程序的演示,请参阅https://nicer.app/wiki/en.wikipedia.org- 搜索栏还不能用... :(
答案1
啊!谷歌搜索(以及按照我在 OP 中的评论)很有帮助 :D
RewriteCond %{REQUEST_METHOD} ^(GET)$
RewriteCond %{HTTP:X-Requested-With} XMLHttpRequest
RewriteRule ^wiki-search/(.*)$ NicerAppWebOS/logic.AJAX/ajax_get_content.php?app-wikipedia.org-search=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_METHOD} ^(GET)$
RewriteRule ^wiki-search/(.*)$ NicerAppWebOS/index.php?app-wikipedia.org-search=$1&%{QUERY_STRING} [L]