#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    5
    Rep Power
    0

    Rewrite rules for different pages issue


    Hello, I have this rule in htaccess file that handles URL for item,

    Options All
    RewriteEngine On
    RewriteBase /www/
    RewriteCond %{THE_REQUEST} \ /www/item\.php\?id=([0-9]+)&([^&\ ]+)
    RewriteRule ^ %1/%2? [L,R=301]
    RewriteRule ^([0-9]+)/(.*)$ item.php?id=$1&$2 [L,QSA,NE]

    in same htaccess I need to handle catlist also
    with this rule:

    RewriteCond %{THE_REQUEST} \ /www/category\.php\?id=([0-9]+)&([^&\ ]+)
    RewriteRule ^ %1/%2? [L,R=301]
    RewriteRule ^([0-9]+)/(.*)$ category.php?id=$1&$2 [L,QSA,NE]

    When I put them together only first one works
    Any solutions or ideas
    Thank You
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,113
    Rep Power
    9398
    That last RewriteRule in each, with the [0-9], is the same for both. You have to choose what "/12345/" maps to: either it's an item or it's a category.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    That last RewriteRule in each, with the [0-9], is the same for both. You have to choose what "/12345/" maps to: either it's an item or it's a category.
    If I understand You adding for ie "i-" for item and leave this rule for category should solve problem, but how to do that i only get numbers, somewhere i make mistake with sintax
    Thanks
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,113
    Rep Power
    9398
    Sure, "i-" will work.

    Syntax errors? What did you try?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    Sure, "i-" will work.

    Syntax errors? What did you try?
    I am not familiar with rewrite rules, so I have changed my php like added I infront of an id, but my rewrite rule then is not right, just dont know how to add i- using this rewrite rule
    Thanks
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,113
    Rep Power
    9398
    I'll rephrase:

    What did you put in your .htaccess that didn't work?

    Comments on this post

    • sz_tech agrees
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by requinix
    I'll rephrase:

    What did you put in your .htaccess that didn't work?
    This one works
    Thanks requnix

    RewriteRule ^I-([0-9]+)/(.*)$ item.php?id=$1&$2 [L,QSA,NE]

    in same htaccess I need to handle catlist also
    with this rule:

    RewriteRule ^C-([0-9]+)/(.*)$ category.php?id=$1&$2 [L,QSA,NE]

IMN logo majestic logo threadwatch logo seochat tools logo