htaccess url rewrite problem

Discussion in 'Programming' started by Nightmare, Dec 17, 2006.

  1. #1
    Hi!

    There is some way to rewrite only url requested from browser and not server?

    I made this url rewrite:

    from
    /singlelink.php?cid=00&lid=11
    to
    /words-00-11.html

    RewriteBase /modules/xdirectory/
    RewriteRule ^([a-zA-Z\_]+)-([0-9]+)-([0-9]+)\.html$ singlelink.php?cid=$2&lid=$3 [L]


    ok?
    at this point, there is no problems...

    but in this way google find duplicate pages... so I need a rule to tell a google that the old pages no longer exists [G]

    I tried with RewriteRule ^singlelink\.php$ - [G], it works but invalidate the first rule too...

    Thanks a lot!!!
     
    Nightmare, Dec 17, 2006 IP
  2. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Isn't that rewriting

    to
    /singlelink.php?cid=00&lid=11
    from
    /words-00-11.html

    If you want to tell google that a page has permanently moved you can use the R flag and code 301 for a permanent move

    RewriteBase /modules/xdirectory/
    RewriteRule ^([a-zA-Z\_]+)-([0-9]+)-([0-9]+)\.html$ singlelink.php?cid=$2&lid=$3 [L,R=301]
     
    streety, Dec 17, 2006 IP
  3. Nightmare

    Nightmare Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't want that users/search engine view singlelink.php and I want to tell to google that the old singlelink.php pages no longer exists.

    I hope you understood this time.

    tnx&bye
     
    Nightmare, Dec 18, 2006 IP
  4. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    RewriteRule singlelink.php?cid=([0-9]+)&lid=([0-9]+) words-$1-$2.html [L,R=301]
     
    streety, Dec 18, 2006 IP
  5. Nightmare

    Nightmare Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    1 - I can't use 301 cause words are dynamic

    2 - after your Rule the server found the other one, and cylce has begun...

    RewriteRule ^([a-zA-Z\_]+)-([0-9]+)-([0-9]+)\.html$ singlelink.php?cid=$2&lid=$3 [L]
     
    Nightmare, Dec 18, 2006 IP
  6. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #6
    use robots.txt to block access and normal rewrite rules ?
     
    krakjoe, Dec 18, 2006 IP
  7. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    1 - Maybe I'm misunderstanding how rewrite works but I don't see why this would be a problem.

    2 - My intention was you would use just this rewrite rule

    [edit]

    I think I misunderstood your intentions

    Placing

    RewriteRule singlelink.php?cid=[0-9]+&lid=[0-9]+ - [PT,L]

    above the rule you have already (ignoring my previously posted) may be what you want.
     
    streety, Dec 19, 2006 IP