Whats wrong with my permalink?

Discussion in 'PHP' started by TheSyndicate, Apr 22, 2009.

  1. #1
    I get an 500 error and when i change back to old one same problem

    RewriteEngine On
    RewriteBase /

    RewriteRule ^company-(.*)\-(.*)\-(.*)\-(.*)\.html$ info.php?id=$1 [L]
    RewriteRule ^category-\(.*)-\(.*)\.html$ search.php?c=$1 [L]
    RewriteRule ^subcategory-\(.*)-\(.*)\.html$ search.php?s=$1 [L]
    RewriteRule ^Addreview-\(.*)-\(.*).html$ Addreview.php?id=$1 [L]
    RewriteRule ^Viewreview-\(.*)-\(.*).html$ Viewreview.php?id=$1 [L]
    RewriteRule ^Print-\(.*)-\(.*).html$ print.php?id=$1 [L]
    RewriteRule ^Friend-\(.*)-\(.*).html$ friend.php?id=$1 [L]
    RewriteRule ^Email-\(.*)-\(.*).html$ email.php?AgentID=$1&ListingID=$2 [L]
    RewriteRule ^Images-\(.*).html$ info.php?id=$1&i=2 [L]
    RewriteRule ^Savelist-\(.*)-\(.*)-\(.*).html$ savelist.php?id=$1&user=$2 [L]
    RewriteRule ^ArticlesDetails-\(.*)-\(.*).html$ articlesdetails.php?id=$1 [L]
     
    TheSyndicate, Apr 22, 2009 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    At the first look I see you are escaping ( but not )

    You've to write more strict regular condition instead .*
    Regards
    Edit: You should carefully check what must be escaped and what must not.
     
    koko5, Apr 22, 2009 IP
  3. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #3
    I did not get that can you tell me more.
     
    TheSyndicate, Apr 22, 2009 IP
  4. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #4
    Here is an example:
    
    RewriteRule ^Email\-([^\-]+)\-([^\-\.]+)\.html$ email.php?AgentID=$1&ListingID=$2 [L]
    
    Code (markup):
    In your code:
    you use only $1 of 4 and you are not escaping all special characters.
    First (.*) is very wide range and includes next -xxx-xxx.html to the end of url.

    Regards
     
    koko5, Apr 22, 2009 IP
  5. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #5
    ok so that will give me a error 500?
     
    TheSyndicate, Apr 22, 2009 IP
  6. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #6
    My example works :)

    My advice is to add line-by-line code in your htaccess and test it step by step.
     
    koko5, Apr 22, 2009 IP
  7. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #7
    Now i got a new version but still some of the links do not work

    RewriteEngine on
    RewriteBase /


    RewriteRule ^company\-([^\-]+)\-([^\-]+)\-([^\-]+)\-([^\-\.]+)\.html$ info.php?id=$1 [L]
    RewriteRule ^Email\-([^\-]+)\-([^\-\.]+)\.html$ email.php?AgentID=$1&ListingID=$2 [L]


    something wrong?
     
    TheSyndicate, Apr 22, 2009 IP
  8. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #8
    Company redirects to info.php
    You can make all these by one line after rewrite condition.
    First portion: company-xxx-xxx.html points to company.php?xxx and s.o. for each one. So rule must start like:^([^\-]+)-...... and points to $1.php?id=$2&Other=$3

    Regards
     
    koko5, Apr 22, 2009 IP
  9. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #9
    lol i wish you online all the time i will check this and come back to you
     
    TheSyndicate, Apr 23, 2009 IP