Redirect from Folder1 to Folder2

Discussion in 'Apache' started by dlmania, Apr 24, 2009.

  1. #1
    Hi,

    I have a blog on my own domain under a folder as www.example.com/blog and the blog posts have URLs like www.example.com/blog/2009/04/abc.html.

    I have now created a new blog in a different folder www.example.com/newblog and these blog posts have URLs exactly similar to the old one.. except for the folder name www.example.com/newblog/2009/04/abc.html.

    I want to redirect some of the URLs from the old blog to the new blog, while retaining the others. I don't want all example.com/blog links to be redirected to example.com/newblog links.. only some as in the folder structure below.

    To summarize, I need to write a redirect for
    www.example.com/blog/2009/04/*
    to
    www.example.com/newblog/2009/04/*

    Can someone please help with the redirect code?
     
    dlmania, Apr 24, 2009 IP
  2. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteRule ^/blog/2009/04/(.*) http://www.example.com/newblog/2009/04/$1 [R=301,L]
     
    Lpe04, Apr 27, 2009 IP
  3. dlmania

    dlmania Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, but I am not able to get this code to work. Does this need to go into the .htaccess file in the root folder or in the /blog folder? I tried both but the redirect was not working. :(
     
    dlmania, Apr 28, 2009 IP
  4. thecren

    thecren Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This doesn't make any sense to me. Why do you want only some of the posts to redirect? Any simple solution will be all or nothing. The difficult solution is to manually place a meta refresh tag in each post you want to redirect.

    In the HEAD tag of every page you want redirected, place this code:
    <META http-equiv="refresh" content="0;URL=http://www.example.com/newblog/2009/04/filename.html">

    The information between quotes in the "content" attribute tell the browser two things: 1) how long to wait before redirecting (in this case 0 seconds), and 2) where to redirect to. You will need to change the filename of course.

    Good luck!
     
    thecren, Apr 28, 2009 IP
  5. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Did you also add
    
    RewriteEngine On
    Rewritebase /
    
    Code (markup):
    ?
    It's hard for me to test without the same files

    Because of what you are trying to do, it has to go in the root directory.

    Cheers,
     
    Lpe04, Apr 28, 2009 IP