Forum Moderators: phranque

Message Too Old, No Replies

Generate 301 redirects by keyword?

         

ichthyous

8:36 pm on Oct 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi there, I have prepared a long list of 301 redirects which I want to add to my htaccess file. The file already contains around 400 redirects. When I added the new batch (approx. 500 redirects) my website crashes. I called tech support and they said that there is no hard-wired upper limit to the number of lines in htaccess, but that the file has to be parsed for every request and that many lines is just a bad idea. He said I should use an application which looks up the redirect in a database and dynamically generates it...I have no clue how to program such a thing. The other option is to use pattern matching to redirect batches of files. I think that will work since many batches of files share at least one keyword. The problem is that many of the pages cross reference subjects and share multiple keywords, so it would be hard to target exactly which redirected page to send them to. For example:

black_and_white_photography.html - should redirect to /photos/black-and-white/
new_york_photography.html - should redirect to /photos/new-york/
black_and_white_new_york_photography.html - should redirect to /photos/new-york/

Would it be possible to create rules which can redirect based just on some keywords in each filename?

wilderness

3:51 pm on Oct 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hopefully another will come along and offer your a regex, however the forum charter prefers that you make an attempt at some type of rewrite on your own and then ask others for correction.

As far as your site crashing (500 error) because of too many entries in the htaccess?

ABSURD (at least for 900 lines).

Your getting a 500 error because you have syntax error (s) in your redirects.

ichthyous

3:56 pm on Oct 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hmm...that's strange because all I am doing is repeating simple redirect lines that are already present in htaccess, and they aren't crashing anything. I will double check that somehow something didn't get mangled.

wilderness

9:22 pm on Oct 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



3:36 pm on Oct. 20, The file already contains around 400 redirects. When I added the new batch (approx. 500 redirects) my website crashes.

10:56 am on Oct 21, I am doing is repeating simple redirect lines that are already present in htaccess, and they aren't crashing anything.

either it is or isn't?
Not sure how it can be both?

ichthyous

9:52 pm on Oct 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What I mean to say is that I am using the same simple Redirect 301 that i am already using in htaccess for 500 other urls. I checked again to see if there are any missing spaces or anything else and all the new redirects are clean...yet when I add them to htaccess I get "Internal server error". My only conclusion is that the number of redirects is causing the problem. I am on a VPS, not a dedicated server...would that be an issue?

g1smd

10:10 pm on Oct 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why don't you try ONLY the new ones, with the old ones temporarily removed. That will show you whether 500 crashes the system, or not.

The try them, say, 100 at a time, until you find a problem. Then you can narrow it down.

ichthyous

3:31 am on Oct 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes I did that already. I found the problem...two urls were missing underscores in the page name and that resolved the issue thanks!