PDA

View Full Version : How to reorganize directory structure and keep urls intact!


lazywolfy
01-14-2009, 07:24 PM
is it possible to reorganize the file/directory structure for a web site and still keep all the urls intact without having to recreate them? (possibly using cgi-script php-script or some other method)

for example:
change path/to/all/images to path/to/images/for/dept1 and path/to/images/for/dept2 etc.

Our file structure is all foxed up and we'll be upgrading the cma soon! >.<
Some of our main problems:
thousands of orphaned images/attachments/files/articles, etc
thousands (if not more) images/attachments/etc all in one folder need to be reorganized into their respective dept folder (too many depts) >.<

thanks

PS...I'm just a low-level peon tryna get a raise! xD

oracleguy
01-14-2009, 08:23 PM
What are you using for your web server? Apache?

lazywolfy
01-14-2009, 08:34 PM
I'm about 95% sure it's on apache.

oracleguy
01-14-2009, 10:01 PM
Well if there is some sort of pattern to the way the files are named and how they are being relocated, you could use mod_rewrite to accomplish your goal. But if there isn't a pattern it would get really messy.

In either case it would just be a stopgap measure, you'd be better off permanently fixing the links in your pages.

lazywolfy
01-14-2009, 10:57 PM
Well if there is some sort of pattern to the way the files are named and how they are being relocated, you could use mod_rewrite to accomplish your goal. But if there isn't a pattern it would get really messy.

In either case it would just be a stopgap measure, you'd be better off permanently fixing the links in your pages.
afaik there's no naming convention or pattern for naming the files....and recreating the urls would be almost impossible considering the number of urls/articles, etc, not to mention trying to get the various departments to recreate all their urls. >.<

What about using something like this in .htaccess:
redirect 301 /wrong_dir/ http://www.mysite.com/right_dir/
Would that be enough or would you also have to list each file name?

oracleguy
01-14-2009, 11:40 PM
That would redirect everything in that one directory to the new directory. If you can do that and you aren't putting some of the files that were in wrong_dir into right_dir and some into some_other_dir then mod_rewrite would work too.

You could always just write a script to go through all your data and update the links too.

lazywolfy
01-15-2009, 12:05 AM
That would redirect everything in that one directory to the new directory. If you can do that and you aren't putting some of the files that were in wrong_dir into right_dir and some into some_other_dir then mod_rewrite would work too.>.<
some files will be moved from wrong_dir to right_dir and other files to some_other_dir....so I guess that wont work! :confused:

You could always just write a script to go through all your data and update the links too.Now you're talking...although I'm wondering if that would work in a CMA like Vignette. Where/how can I find out more details about this option?

oesxyl
01-15-2009, 12:10 AM
afaik there's no naming convention or pattern for naming the files....and recreating the urls would be almost impossible considering the number of urls/articles, etc, not to mention trying to get the various departments to recreate all their urls. >.<

What about using something like this in .htaccess:
redirect 301 /wrong_dir/ http://www.mysite.com/right_dir/
Would that be enough or would you also have to list each file name?
using rewrite mode will slow down the server anyway but when is abused, overused or missused become a big problem.
When you reorganize your server is very easy to mess up everything if you don't have a clear plan what, how and when to do what you have to do.
I guess this links, along with oracleguy help, can help you a little:

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide_advanced.html
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide_advanced.html#filereorg
http://httpd.apache.org/docs/2.2/urlmapping.html
http://httpd.apache.org/docs/2.2/misc/rewriteguide.html

My intention was to put the links sorted by knowledge level and how close are to your problem but I'm not sure about result, :)

best regards