How To Rename Hundreds of Folders without Breaking Links?

  • njoedits
  • Born
  • Born
  • njoedits
  • Posts: 2

Post 3+ Months Ago

I need to rename hundreds of folders on a website with over 100,000 hand-coded HTML, ASP, and CFM pages. Obviously I'd like to do this without breaking thousands of links across the site.

What is the best way to accomplish this?

Is the best way with a server-side configuration (mod_rewrite)? Is there software available that could do a batch rewrite of URLs in the HTML, ASP, and CFM files?

Thanks!

-Nicholas
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

http://download.cnet.com/Batch-File-Ren ... 81978.html

Would that work?
  • njoedits
  • Born
  • Born
  • njoedits
  • Posts: 2

Post 3+ Months Ago

Unfortunately, no, a simple batch renaming application is insufficient. Sure, it will rename the folders, but it will leave all the URLs in the HTML, ASP, and CFM unchanged. Thus, it will result in thousands of broken links.

I need an approach that changes the folder names and all the corresponding URLs in all the files of the website.

Thanks in advance for further suggestions!

-Nicholas
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

Good luck. I hope you find what you need but let me ask a question. Why is it necessary to rename all those folders?
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

You need regular expressions. I'd say a utility script of some flavor (bash/perl/etc) would be your best bet. It's a pretty unusual request, so I would imagine a custom solution would best suit your needs.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

The HTML files shouldn't be hard to run through a DOM parser and replace a few attributes in assuming it's valid XML/HTML.

The ASP/CFM stuff is going to be more complicated though because you have to take into account programming that builds URLs that you can't know about unless you execute the ASP/CFM programming. I've not seen something that can do this.

mod_rewrite is kinda hinky because you'll end up doubling the requests to your server for both the affected pages and every resource in each page, at least for their first load.

One thing that comes to mind here is to rename the folders, then create symlinks named using the old names and pointing to the new names. That way the resources can be accessed using both the old and new names.

That introduces an issue with pages being accessible via two URLs though.

What could be done is to then use mod_rewrite to only rewrite requests for pages that use the old folder names, basically anything with a text/html mime-type, and sending a 301 redirect for those to the new folders.

That would double the number of requests to the server for pages, but not affect the number of requests for things such as images/css/etc within pages because though they should still be accessible because of the symlinks and not require rewrites/redirects.

Kinda tough to come up with anything given the absence of details about the big picture here though. :)

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 52 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.