Apache redirect / redirect

I have a project for migrating from an old system to a new system. Moving to the new system will create a new unique identifier for the objects being transferred; however my users and search indexes will have urls with old ids. I would like to set up an apache redirect or redirect to handle this, but I'm worried about performance with so many objects (I expect with 500K ID mappings the old ID will be mapped to the new ID mappings).

Has anyone implemented this at this scale? Or knows if apache can handle this big redirect?

+2


source to share


4 answers


If you have a fixed set of mappings, you must specify mod_rewrite rewrite map of type Hashfile. Try it.



+2


source


I had the same question lately. Since I couldn't find a practical answer, we implemented 6 htaccess rules, of which 3 had 200,000 conditions.
This means that the htaccess file is 150MB in size. This was actually fine for half a day where no one was using that particular website, even though the page load times were in seconds. However, the next day our entire server was hammered, with loads much higher than 400. (machine - 8 cores, 16 GB of RAM, SAS RAID5, so there are usually no problems with resources)

I suggest if you need to implement something like this. Create your rules so they don't need conditions and put them in the dbm rewrite map. this easily resolved performance issues for us.



http://httpd.apache.org/docs/current/rewrite/rewritemap.html#dbm

+2


source


Can you talk about rewriting using fewer rules? Is there a pattern that associates old urls with new ones?

If not, I will worry about Apache with 500K + rewrite mappings that will just go through its comfort zone. However, this may surprise you.

It looks to me like you need to write a database-enabled application to handle redirects, with the mapping itself being stored in the database. It will be much better.

+1


source


I see this is an old topic, but have you all found a solution?

I have a case where developers use htaccess to redirect over 30,000 urls using RedirectMatch

in a file .htaccess

.

I'm worried about performance and management bugs given the size of this file.

I recommended since all old urls have:

/sub/####

      

So that they move this to the database and create

/sub/index.php

      

Redirect all requests to:

www.domain.com/sub/###

to

www.domain.com/sub/index.php

Then index.php sends a redirect as new urls and old ids can be found in the database.

This way, only HTTP requests for old URLs will remove the rewrite processes instead of every single HTTP request.

+1


source







All Articles