1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirect old URLs with .htaccess

Discussion in 'WordPress' started by giorgioarmani, May 8, 2016.

  1. #1
    I would like to redirect all traffic from old urls to new urls with the folder structure changing:

    domain.com/old/page/
    domain.com/new/page/

    Anyone know how to do this?
     
    giorgioarmani, May 8, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Well, since you're changing the folder structure, you'll need one rule per change - so that domain.com/one-old/page/ goes to domain.com/one-new/page, and so on.

    Which means you would need something like this:
    Redirect 301 ^domain.com/old_1/page ^domain.com/new_1/page
    Redirect 301 ^domain.com/old_2/page ^domain.com/new_2/page
     
    PoPSiCLe, May 8, 2016 IP
  3. giorgioarmani

    giorgioarmani Well-Known Member

    Messages:
    2,633
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Thanks buddy! I tried adding this to htaccess but get a 500 server error:

    Redirect 301 ^mydomain.com/oldfolder/page ^mydomain.com/newfolder/page

    I forgot to mention that /page can be any page so I guess that needs to be different.
     
    giorgioarmani, May 8, 2016 IP
  4. giorgioarmani

    giorgioarmani Well-Known Member

    Messages:
    2,633
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    160
    #4
    OK got it. This is what I used:

    RewriteRule^old/(.*)$ /new/$1 [L,R=301]
     
    giorgioarmani, May 9, 2016 IP