Is it really that simple - redirecting a single file on IIS
For various reasons, I've been working towards migrating from an Apache server to an IIS one for my sites. For Gavin's site, I couldn't get away with it, but I don't have any problem making things more difficult for myself :D
However, this means that old URLs may not be working as they should.
My experience with IIS is a working knowledge of it, and therefore I know what I need to know, picking up what I can. One thing that I've had a hard time with is figuring out how to do 301 redirects for individual files.
For folders, it's easy enough. So, if the file names have stay the same, but the folder structure has changed, it's easy to setup a redirect.
For domains, it's also easy enough. So, if the domain has changed, but the folder structure and file names have stayed the same, it's easy to setup a redirect.
For individual files, I know now that it's easy enough to enable 301 redirects as well. Well, not quite as easy as Apache, but ...
I've got a file at http://domain/foldername/filename.ext but that should now go to some other file at http://newurl
For Apache, you can add the following to your .htaccess file, in the domain's root folder:
redirect 301 /foldername/filename.ext http://newurl
Unfortunately, IIS doesn't have a way to change these via a file (at least, not built-in to IIS 6). But, you can create that file using the old structure, if it doesn't already exist.
Next, open IIS Manager and navigate to the file.
Now right click on the file, select Properties, and change the first option in the File tab from "The designated file" to "A redirection to a URL" and enter the new, full, url into the "Redirect to" field.
"The exact URL entered above" and "A permanent redirection for this resource" should also be selected, as necessary.
I just wish I would have known about this some time ago.
- Review: JLHua Silicone Multi-Use Cartoon Cat Trivet Mat (set of 6 Pack) Insulated Flexible Durable Non Slip Hot Pads and Coasters Cup Mats
- Review: Tash-Kalar: Arena of Legends
- Review: Babymoov Dream Belt – Maternity Sleep Support & Cushion for Ultimate Comfort during Pregnancy
- Review: AmazonBasics PlayStation 4 Controller Charging Cable
- Review: Galaxy Trucker
Support This Site
If my blog was helpful to you, then please consider visiting my Amazon Wishlist.