Help: changing urls + a "moved permanently" redirect

Discussion in 'Apache' started by myamar, Mar 17, 2006.

  1. #1
    I've made a big mistake with my wordpress blog:

    The url to an article is set to be: http//blog.com/subject-id.html

    Since I've seen that url like index.php/2/ are getting indexed, I've asumed that google will index my long articles "subject-id.html/2/"

    Boy, I was wrong!

    Now I need to remove the ".html" part, which is easy in wordpress, BUT I want to make a "moved permanently" redirect also.

    Anybody has a solution to this problem? :)
     
    myamar, Mar 17, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Ouch!!!!! I'm not sure if it's possible, since there is the original URL plus two different fake URLs. You might get the infinite loop. Post three URL examples.

    Original URL, current URL, and how you want it.

    How long have you given Google to index the pages and how old is the site?
     
    Nintendo, Mar 17, 2006 IP
  3. myamar

    myamar Active Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    73
    #3
    I've did it!

    I've changed the urls.

    I've got about 600 posts in 4 months, a few external links pointing to posts (that will get a 404 error now).

    About 50 posts have 2-5 pages, they are the 1st reason I've decided to change the urls.

    80% of my 400 visitors/day come from SERP to internal pages mostly, I guess traffic will be down for a few days, just have to wait...
     
    myamar, Mar 23, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Do you have an original 301 redirect? I tested it out early today, and it is possible to have a redirect to a new URL after changing a mod_rewrite URL.

    Post a URL in all three formats, original php URL, first mod_rewrite URL, and current URL.
     
    Nintendo, Mar 23, 2006 IP
  5. myamar

    myamar Active Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    73
    #5
    Here is a part from the old .htaccess:

    RewriteRule ^([^/]+)-([0-9]+).html/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?name=$1&p=$2&feed=$3 [QSA,L]
    RewriteRule ^([^/]+)-([0-9]+).html/(feed|rdf|rss|rss2|atom)/?$ /index.php?name=$1&p=$2&feed=$3 [QSA,L]
    RewriteRule ^([^/]+)-([0-9]+).html/page/?([0-9]{1,})/?$ /index.php?name=$1&p=$2&paged=$3 [QSA,L]
    RewriteRule ^([^/]+)-([0-9]+).html(/[0-9]+)?/?$ /index.php?name=$1&p=$2&page=$3 [QSA,L]


    and same part from the new .htaccess:

    RewriteRule ^([^/]+)-([0-9]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?name=$1&p=$2&feed=$3 [QSA,L]
    RewriteRule ^([^/]+)-([0-9]+)/(feed|rdf|rss|rss2|atom)/?$ /index.php?name=$1&p=$2&feed=$3 [QSA,L]
    RewriteRule ^([^/]+)-([0-9]+)/page/?([0-9]{1,})/?$ /index.php?name=$1&p=$2&paged=$3 [QSA,L]
    RewriteRule ^([^/]+)-([0-9]+)(/[0-9]+)?/?$ /index.php?name=$1&p=$2&page=$3 [QSA,L]

    Do you think it is possible, at least, to redirect visitors who get now a 404 from "/article-123.html" to index or, even better, to "article-123/"?
     
    myamar, Mar 24, 2006 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    Add
    and test them out.
     
    Nintendo, Mar 24, 2006 IP
  7. myamar

    myamar Active Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    73
    #7
    Thanks, I really apreciate your help.

    Now there is a problem:

    I got a page like http://bacau.ido.ro/ziarul-de-bacau-382/
    When I try the old page: bacau.ido.ro/ziarul-de-bacau-382.html
    It redirects me to: bacau.ido.ro/ziarul-de-bacau-382?/%3f

    What to change here:
    RewriteRule ^([^/]+)\-([0-9]+)\.html(/[0-9]+)?/?$ /$1-$2$3?/? [R=301,L]
    to just redirect "-382.html" to "-382/" ?

    I do not need that urls like "stuff-382.html/page/2/" or "stuff-382.html/2/" to make a redirect since google didn't crawl any of this urls.

    Tkanks.

    Update:
    I've changed
    RewriteRule ^([^/]+)\-([0-9]+)\.html(/[0-9]+)?/?$ /$1-$2$3?/? [R=301,L]
    with
    RewriteRule ^([^/]+)\-([0-9]+)\.html(/[0-9]+)?/?$ /$1-$2$3/ [R=301,L]

    and the redirect url looks ok.

    Do you think it's the right move?
     
    myamar, Mar 24, 2006 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    I think geting rid of that ? would get rid of it. I think the %3f is the browsers version of ?.
     
    Nintendo, Mar 24, 2006 IP
  9. myamar

    myamar Active Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    73
    #9
    It works ok, thank you for your help, Nintendo.

    You're the king :)
     
    myamar, Mar 26, 2006 IP