Redirect 301 .htaccess Question

Discussion in 'Apache' started by cguedez, Jun 26, 2011.

  1. #1
    Hi all,

    I am a new member. I don't know much about .htaccess and I hope somebody can help me.

    My website is: www.carmenguedez.com

    I have moved all my .html (paintings) to .php from the gallery folder. See examples:

    redirect 301 /gallery/tres_llaves.html http://www.carmenguedez.com/gallery/tres_llaves.php

    redirect 301 /gallery/vintage.html http://www.carmenguedez.com/gallery/vintage.php

    redirect 301 /gallery/true_story.html
    http://www.carmenguedez.com/gallery/true_story.php

    redirect 301 /gallery/peace-and-love.html http://www.carmenguedez.com/gallery/peace-and-love.php

    I have many paintings and I would like to know if I can reduce all these codes to only one code using either redirect 301 or mod_rewrite, whatever is best.

    I would appreciate your help.

    Thanks,

    Carmen
     
    cguedez, Jun 26, 2011 IP
  2. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you have any pages that are still .html?
    If you convert all of them to .php
    then just do a
    RewriteRule ([^\.html]*).html http://www.carmenguedez.com/$1.php [L, R=301]
    In mod_rewrite
     
    ntomsheck, Jun 27, 2011 IP
  3. cguedez

    cguedez Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I do have .html pages.

    Thanks for replying.
     
    cguedez, Jun 27, 2011 IP
  4. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try to find some common ground between all the php pages then. For example, are all the pages within the gallery folder in .php? If so, you could just prepend a /gallery/ before the regex I gave.
     
    ntomsheck, Jun 27, 2011 IP
  5. cguedez

    cguedez Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, all .php pages are within the gallery folder.

    Sorry for my ignorance! I added this code to my htaccess and gave me a 500 internal server error:

    RewriteEngine On
    RewriteRule ([^gallery\.html]*).html http://www.carmenguedez.com/gallery/$1.php [L, R=301]

    What I am doing wrong?

    Thanks so much.
     
    cguedez, Jun 28, 2011 IP
  6. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sorry, I should have been a little more specific.
    /gallery/([^\.html]*).html http://www.carmenguedez.com/gallery/$1.php [L, R=301]
     
    ntomsheck, Jun 29, 2011 IP