Help me to make my .HTACCESS file for a php site

Discussion in 'PHP' started by templatese, Aug 22, 2008.

  1. #1
    Hi

    I want to make my urls seo friendly but don't know how to use the htaccess file for that.

    I have some urls:

    1- www.mysite.com/list.php?category=xyz  
    Change to: www.mysite.com/xyz
    
    and 
    2- www.mysite.com/details.php?product=productname 
    Change to:  www.mysite.com/xyz/productname
    Code (markup):
    how to make this urls with htaccess file?
     
    templatese, Aug 22, 2008 IP
    NatalicWolf likes this.
  2. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine On
    RewriteRule ^(.*)$ list.php?category=$1
    RewriteRule ^(.*)/(.*)$ list.php?product=$2

    I used (.*) because it will accept any data...Thats so you can have spaces and stuff in the name or numbers too...Hit me up if you need help.
     
    NatalicWolf, Aug 22, 2008 IP
  3. templatese

    templatese Banned

    Messages:
    176
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, but it doesn't work properly :(
    when I use this code other pages don't work properly and they can't read the css file in root of my site.

    any idea for it?
     
    templatese, Aug 22, 2008 IP
  4. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here you go, this should help a bit:

    RewriteEngine On
    RewriteRule ^l-(.*)$ list.php?category=$1
    RewriteRule ^l-(.*)/p-(.*)$ list.php?product=$2


    l = list
    p = product
    There, no more issues should be seen if you follow that standard.
     
    NatalicWolf, Aug 22, 2008 IP
    templatese likes this.
  5. templatese

    templatese Banned

    Messages:
    176
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks

    another question:

    I have the same problem for another site.

    mysite.com/layouts.php?keyword=abstract

    I want to change this url to:

    mysite.com/abstract.html

    any idea about this?
     
    templatese, Aug 23, 2008 IP
  6. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    well...if you pm me, we can talk about how to do that...Message me on any client you have or pm me here with another option.
     
    NatalicWolf, Aug 23, 2008 IP