Changing domain names: A solution!

DrDavidDrDavid Registered Users Posts: 1,292 Major grins
Here's what I did... I originally used one domain (we'll call it photos.original.com) and wanted to replace it with a new domain (www.new.com).. BUT, I had already given out links with the photos.original.com URL (and didn't want to break those), plus, I wanted to be able to use www.new.com as the 'official' smugmug domain. SO... Here's the trick:

For www.new.com, set that domain up the way you'd set up any other domain on smugmug. Point the A to smug's IP address, the CNAME to @, and use www.new.com as your smugmug virtual domain name.

Now, for the sneaky part. You'll need access to a linux host for this (i.e. Apache). I'd be willing to host these redirects for a small fee too (I have a very fast machine, and a very fast internet connection).

First, point your photos.original.com to your linux box's IP address/cname.

I use Ubuntu, so, you may need to modify the path a bit, but, in my case, I created a new file in /etc/apache2/sites-available called "photos.original.com", then paste the following (changing where needed)
[php]
<VirtualHost *>
ServerName photos.original.com
RewriteEngine on
RewriteLog /var/log/apache2/photos.log
RewriteLogLevel 2
RewriteRule ^/(.*)$ http://www.new.com/$1 [L]
</VirtualHost>
[/php]
Last, go to /etc/apache2/sites-enabled and use the command

ln -s ../sites-available/photos.original.com

of course, the filename should be whatever you actually called it. Restart apache, and voila.. It works. Requests to photos.original.com/gallery/132432342#23423423 are rewritten as www.new.com/gallery/132432342#23423423 and the user sees the new URL in their browser. BUT, all the old links WORK!
Now, technically, you should be able to use the rewrite rule in an .htaccess file, but, I was too lazy to create a new directory, etc. Anyways, hope this helps someone! :)
To be clear, this is a way to do two things:
1) You can use this method to create a 'virtual domain' for non-pro users. Of course, the user will be redirected to yourname.smugmug.com/whatever, but, at least your emailed links can look nicer
2) You can use this method to move one domain to another without losing/breaking any links

David

* Sorry for the cross-post, but, I thought it belonged in the hacks board as well as the original reply...
Sign In or Register to comment.