Forum Moderators: phranque

Message Too Old, No Replies

Site Restructuring: Redirect Advice

I am looking to redirect 1200 urls.

         

djmick200

12:56 pm on Oct 25, 2006 (gmt 0)

10+ Year Member



Over the past 6 years my site structure has become a mess for various reaons including lack of experience/knowledge.

I simply want to rename many of the url's and move them into perhaps 5 or 6 directories. They are currently spread over 30.

Could anyone offer advice on the best method to accomplish this? I have read all morning and have seen various methods suggested. Now Im simply not sure which one to use.

Not being technically gifted would the following be suitable?
RewriteEngine on
RewriteRule ^olddir1/page1\.htm$ newdir/new1.htm [R=301]
RewriteRule ^olddir2/page12\.htm$ newdir2/new1.htm [R=301,L]

The site has 1000's of IBLs. I guess the redirects would remain in place indefinately for the IBLs?

Would having so many redirects in my htacess file slow the server down (dedicated and this is the only site on it)?

My htacess file at present has the following info in it:
/index.html to /
non www to www
ban list for image grabbers
hotlink prevention
error docs

Thanks for any advice

Mick

jdMorgan

1:09 am on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For an external redirect in .htaccess, the proper form is:

RewriteRule ^olddir1/page1\.htm$ http://www.example.com/newdir/new1.htm [R=301]
RewriteRule ^olddir2/page12\.htm$ http://www.example.com/newdir2/new1.htm [R=301,L]

If you are on a dedicated server, look into putting the code into httpd.conf instead of .htaccess; Code in .htaccess is interpreted for each and every incoming HTTP request. Code in httpd.conf is compiled once when you restart the server, and then runs much more efficiently for each request.

The syntax differs slightly, in that a leading slash is needed in the RewriteRule pattern:


RewriteRule [b]^/o[/b]lddir1/page1\.htm$ http://www.example.com/newdir/new1.htm [R=301]
RewriteRule [b]^/o[/b]lddir2/page12\.htm$ http://www.example.com/newdir2/new1.htm [R=301,L]

As far as how much 1200 rules might load the server, that all depends on your traffic level. At 10,000 hits per day, the impact would be negligible; at 1,000,000 hits per day, you might notice it. (A "hit" as used here is an HTTP request for any resource -- a page, an image, CSS file, external JS file, etc.)

Note that in httpd.conf, you could enclose the code in a <LocationMatch> container, so that it only runs for requests for URLs starting with some specified path, such as "^/olddir[0-9]+". Doing so would mean that over time, as your incoming links get updated, the rules would have less and less of an effect on performance. You could also do much the same thing by putting the code into .htaccess files in the "olddir" directories themselves - the code would then only run if those old directories were accessed. A final alternative, though not as good, is to use a rule such as:


RewriteRule !^olddir - [L]

ahead of the rules above, which would tell mod_rewrite to quit immediately if the requested URL-path does not start with "olddir" -- The usability of this method depends on how common the old directory names are, and is not very useful if there are more than a few old top-level directories. Example:

RewriteRule !^(olddir1¦olddir12¦veryolddir1¦ancientdir1) - [L]

Replace the broken pipe "¦" characters in the examples above with solid pipe characters before use; Posting on this board modifies the pipe characters.

Jim

djmick200

9:10 am on Oct 26, 2006 (gmt 0)

10+ Year Member



Hi Jim

Thanks for the detailed reply.

The server gets around 600,000 hits a day. If I was to add the rules to each olddir directory via htaccess perhaps 5 directories at a time over a two or three week period would that lessen the impact on server load? I ask this as the majority of the traffic is SE generated and my thought being that when the new urls and directories are picked up by the bots and appear in the indexs then the bulk of the traffic would be getting sent straight to the new urls.

Perhaps I am missing the whole point of how this works in saying the above.

jdMorgan

2:10 pm on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you've not missed the point. Rather than relying on a specific timetable, though, you might consider watching the server load (or site responsiveness) and adding new rules as indicated, rather than saying, "I'll add new rules every three weeks." Some search engines may pick up the changes immediately, while others may not. Also, consider the possibility of a search index roll-back.

There are simply too many variables to guess at whether you'll see a performance problem. But do note that I said that at 1,000,000 hits per day, you might notice it -- I didn't say that it would slow your site down to the point where it's unusable -- That's fairly unlikely. There are some awfully-big sites using dynamic page-generation scripts that place a far higher load on the server than a few hundred lines of rewrites would do.

The best approach is to test, either with your 'staged roll-out' plan, or with a short all-at-once trial. Then act according to the results of your testing.

Jim