Redirecting to the New Location of a File


#1

I have a couple of files—mostly MP3s—that I need to move to a different directory. How do I redirect users who click on a link to the files’ old location to the files’ new location?


#2

Edit the links.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

If the links are on other sites, this may make it difficult. Plus, I think the right approach would be a couple of entries in .htaccess, but I’m pretty weak with .htaccess, so I didn’t suggest it.

-Scott


#4

If it were that simple, I’d’ve already done it.


#5

Could you indicate why it’s difficult?

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#6

More or less what Scott said. The links have been posted and e-mailed as TinyURLs. I can’t edit the posts or the have the URL link to a different location.


#7

In the case of a couple of files, you should be able to symlink to where they are now on the account.

shell -> cd old dir

ln -s [color=#0000CC]~/domain.com/new/dir/path/name1.mp3[/color] [color=#00CC00]name1.mp3[/color]

So in the old dir you’ll have [color=#00CC00]name1.mp3[/color] which is a link to [color=#0000CC]name1.mp3[/color]

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#8

Wow. I understand the concept, but the execution went way over my head. Could you describe the steps more explicitly? Thanks for the help.


#9

This creates an alias that points to where you’ve now put the files.

Log into your Shell account, using PuTTY, or whatever shell software you have.

Use the ‘cd’ command to go to where your files used to be:
cd ~/example.com/data/music/
~ is your home directory, then inside your domain directory you have your other directories.

I’d do the ln command a little bit different. sXi’s is clearer, but I make my links relative:
ln -s …/newdir/name1.mp3 .

ln is the link (make alias) command
-s makes it symbolic (the nice way to do it)
… means go up one directory. …/… would be go up two directories, and so on.
newdir is the new location
name1.mp3 is the file you moved to the new location
. means keep the same file name and put the alias RIGHT HERE (where it used to be)

http://wiki.dreamhost.com/Putty

-Scott


#10

It’s like creating a “shortcut” in a Desktop environment.

  • Login to shell and cd (change dir) into the old_dir

  • Move the files to their new location, noting down the names and new locations of the files you’ve moved.

  • Now just setup the symlinks in old_dir using the template above.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#11

If this forum was a betting race, I’d owe Scott about 15 internets by now :wink:

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost