Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewrite Maps in IIS Make web.config Too Large

I am migrating a website which is/will be running on IIS and I will be using rewrite maps to 301 redirect old ".asp" URLs to a new style of URL. For many thousands of URLs there is no pattern, so it appears I must rely on rewrite maps.

My problem is that the default web.config size limit is 250kb, and in my environment, I don't have access to change this (as can be done at the registry level - if one had access).

I have looked into moving the rewriteMaps section to an external file, but the external files also have the default size limit of 250kg, so this is also not going to work.

I am looking for some other way to handle this... I am sitting at 242kb currently and have over twice the amount of old to new redirect mapping to add.

Thanks in advance.

like image 543
GWR Avatar asked Aug 06 '15 01:08

GWR


1 Answers

As I am in a shared environment, there was no solution other than to move it to a single external config file, which was again, limited to 250KB.

So here is what I did:

I filled up the map to capicity with the highest-trafficked redirects and of course any groups of urls that could be redirected using a pattern (so they would be fastest).

For the 100k remaining long-tail of the redirects, I put them into a REDIRECTS table in the db... SO, after the request passes all of the rewrite rules in the file (and of course, doesn't hit any), it defaults the request to a certain script. One of the first things the script does is check the REDIRECTS table, and if an entry exists, I do a redirect in the code... it's slower, but most of the stuff in the table is long tail, and as I said, the most visited redirects are still in the file. This has worked well for me so far, and I can add as many redirects as I want... e.g. if a page title/url gets edited, my admin area automatically adds the redirect, etc.

like image 116
GWR Avatar answered Sep 21 '22 06:09

GWR