How to rewrite/redirect a folder name with .htaccess

Discussion in 'Search Engine Optimization' started by jpf566, Dec 13, 2013.

  1. #1
    I have a folder in my site that I want to rename. I don’t want to just rewrite the URL and keep my old folder name, I want to change the folder name and then do whatever is necessary with .hataccess to not lose search engine rankings. The folder name I want to change has a space in it and also is misspelled (whoops x2)

    Example.

    Mysite.com/old foldr/page.html
    Mysite.com/newfolder/page.html

    How would I go about doing this with .htaccess? Do I just switch the folder name on my server and then set up a redirect, or do I do a rewrite? Sorry now familiar with the terms or .htacces.

    Thanks all
     
    jpf566, Dec 13, 2013 IP
  2. jk.deff

    jk.deff Active Member

    Messages:
    59
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    55
    #2
    RewriteEngine on
    RewriteRule ^old\sfoldr/(.+) /newfoldr/$1 [R=301]

    \s means any space symbol.
     
    jk.deff, Dec 16, 2013 IP
  3. John Dave

    John Dave Active Member

    Messages:
    873
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    80
    #3
    RewriteEngine on
    RewriteRule ^old foldr/(.*) newfolder/$1
     
    John Dave, Dec 17, 2013 IP