Forum Moderators: phranque
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
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]
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]
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]
RewriteRule !^(olddir1¦olddir12¦veryolddir1¦ancientdir1) - [L]
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.
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