我想将子目录重定向到.htaccess中的URL参数就像这样:domain.com/search/123 -〉domain.com/searchresult?search=123这在.htaccess中是如何实现的
58wvjzkj1#
你检查过mod_rewrite了吗?甚至还有一个“重写查询字符串”的例子:此解决方案与前面的解决方案相反,将路径组件(可能是PATH_INFO)从URL复制到查询字符串中。
mod_rewrite
# The desired URL might be /products/kitchen-sink, and the script expects # /path?products=kitchen-sink. RewriteRule "^/?path/([^/]+)/([^/]+)" "/path?$1=$2" [PT]
--https://httpd.apache.org/docs/current/rewrite/remapping.html#rewrite-query
sirbozc52#
应该可以与
RewriteEngine On RewriteRule ^/(.*)$ searchresult?$1=$2 [R=301,L]
2条答案
按热度按时间58wvjzkj1#
你检查过
mod_rewrite
了吗?甚至还有一个“重写查询字符串”的例子:
此解决方案与前面的解决方案相反,将路径组件(可能是PATH_INFO)从URL复制到查询字符串中。
--https://httpd.apache.org/docs/current/rewrite/remapping.html#rewrite-query
sirbozc52#
应该可以与