从地图文件重写Apache URL

时间:2019-03-08 06:54:33

标签: php apache .htaccess mod-rewrite url-rewriting

我在名为“ map.txt”的映射文件中有一个URL映射列表,其内容如下:

find-a-partner/company-profile/?profileID=27  
 https://www.example.com/integrations/payment-processing/dp-checkscan/

find-a-partner/company-profile/?profileID=79  https://www.example.com/integrations/auctions-events/agile-ticketing/

我想要实现的是,当输入此“ https://test-connect.example.com/find-a-partner/company-profile/?profileID=27”时,应将其重定向到地图文件中列出的此URL:“ https://www.example.com/integrations/payment-processing/dp-checkscan/”。我尝试使用以下代码,但未正确重定向

   # Match back to URI + QUERY string in the MAPFILE
RewriteCond %{REQUEST_URI} (.*)
RewriteCond %{QUERY_STRING} (.*)
RewriteCond ${mapfile:%1\x3f%2|NOT_FOUND} !NOT_FOUND
RewriteRule . ${mapfile:%1\x3f%2} [NC,NE,R=301,L]

# Match back to QUERY string in the MAPFILE
RewriteCond %{QUERY_STRING} (.*)
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteRule .? ${mapfile:%1} [NC,NE,R=301,L]

0 个答案:

没有答案