Re: RewriteMap values including query strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I came across the post at http://www.webmasterworld.com/forum92/1400.htm and it appears to have met my needs.  Below is the config I'm having success with so far.  Will have to see what I can do to tweak and make it more efficient, but I can confirm it's allowing me to use a single rewrite map file with source URLs that do and do not contain query strings.  No destination URL contains a query string.  I'll have to do some testing to see if I notice much of a difference in performance if I convert it to a dbm file too.

RewriteEngine on
RewriteMap rdm txt:/apps/httpd-2.4.10/conf/extra/redirects/redirect_map.txt

#Base URL contains a query string
RewriteCond %{QUERY_STRING} !=""
RewriteCond %{REQUEST_URI} !=""
RewriteCond ${rdm:%{REQUEST_URI}?%{QUERY_STRING}|NOT_FOUND} !=NOT_FOUND
RewriteRule ^.*$ ${rdm:%{REQUEST_URI}?%{QUERY_STRING}}? [R=301,L]

#Base URL does not contain query string
RewriteCond %{QUERY_STRING} !.
RewriteCond %{REQUEST_URI} ^(.*)
RewriteRule ^.*$ ${rdm:%1} [R=301,L]

On Mon, Jan 19, 2015 at 4:34 PM, Doug Strick <douglas.strick@xxxxxxxxx> wrote:
I'm working on adding some 301 redirects for some sites we're migrating.  I've been given a large list of 1:1 redirects.  The majority of URLs include a query string.  I've included the the full 1:1 URL mapping list in my redirect map text file.  I'm finding issues when testing the URLs that contain query strings.  I've tried reading the documentation on RewriteMap and I'm guessing it just doesn't go deep enough to include 1:1 mappings for query strings.  Below are some example URLs in my rewrite map file.  Any suggestions on how I should set up my redirects to account for all of them in 1 rewrite map file?  I'm ok with using different rewrite rule blocks in my configs, but would prefer not to have to break up this map list as it's almost 15K lines.  Thanks


http://www.example.com/ --> http://www.test.com/us/en/main.html
http://www.example.com/?ps=1 --> http://www.test.com/us/en/main.html
http://www.example.com/browse.cfm?prdID=99ABCDE-88FG-77HI--66JKLMNOP --> http://www.test.com/shop/catalog/item/12345
http://www.example.com/pdfs/iteam-A.pdf --> http://www.test.com/shop/catalog/item/112233
http://www.example.com/Products/View.cfm?cat=ItemClass&ID=0123ABC --> http://www.test.com/us/en/main/category1/subcategory1/productDetail.html
http://www.example.com/previews/?d=7788 --> http://www.test.com/us/en/main/category1/subcategory2/productDetail.html
http://www.example.com/Products/Search.cfm?prdID=88900ABCDEF-77GH-66IJ-55KLMNOP --> http://www.test.com/us/en/main/category1/subcategory2/productDetail.html



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux