Please help me redirect visitors to my blog, from a subdomain to a subdirectory...
December 19, 2008 7:48 AM   Subscribe

I have a blog, which I did have available at blog.example.com. I have recently moved it to be a subdirectory of my main site www.example.com/blog. I am having some trouble with redirecting old links from the subdomain across the the new main site subdirectory, and I really need some help to get it working right. can someone help me craft a .htaccess file to handle the redirects?
posted by Scramblejam to Computers & Internet (5 answers total) 3 users marked this as a favorite
 
Is the docroot the same?
posted by four panels at 8:00 AM on December 19, 2008


Try this:

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^ http://sub.domain.com [R,L]
posted by camworld at 8:07 AM on December 19, 2008


You can also do a simple php redirect, just throw this into the blog.mysite.com directory as index.php:

[?php
header( 'Location: http://www.mysite.com/blog/' ) ;
?]

posted by four panels at 8:15 AM on December 19, 2008


You can also do a simple php redirect, just throw this into the blog.mysite.com directory as index.php

that will redirect people visiting blog.scramblejamble.com directly, but will do nothing to redirect old links.

here's my best crack at what you need to put in .htaccess:
RewriteEngine On
RewriteRule ^http://blog.scramblejam.com/(.*)$ http://www.scramblejam.com/blog/$1

posted by namewithoutwords at 8:27 AM on December 19, 2008


Why use mod_rewrite if you don't have to? Use mod_alias's Redirect directive.
posted by mkb at 8:51 AM on December 19, 2008


« Older Asking for tuition support instead of a raise   |   They don't make 'em like they used to Newer »
This thread is closed to new comments.