PHP Url Re Wrtitng

Discussion in 'PHP' started by rizmy, Jun 28, 2010.

  1. #1
    hi
    i need to rewrite following url usin php or htacces file
    mysite.com/browse.html?level=50&categoryname=mobilephones
    as
    mysite.com/mobilephones.html

    is there any possible answers?
     
    rizmy, Jun 28, 2010 IP
  2. Michellu

    Michellu Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Don't you also need the level to display?
    If you do you will want to rewrite it to something like
    mysite.com/mobilephones_lvl50.html

    which you would do by adding this to your .htaccess
    RewriteRule ^(.*)-lvl([0-9]+).html$ browse.html?categoryname=$1&level=$2

    If you don't need the level and you want to re-write to mysite.com/mobilephones.html you would simply put:
    RewriteRule ^(.*).html$ browse.html?categoryname=$1
     
    Michellu, Jun 28, 2010 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    mfscripts, Jun 28, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Here it goes

    
    RewriteEngine On
    RewriteRule ^([^/]*)\.html$ /browse.html?level=50&categoryname=$1 [L]
    
    Code (markup):
     
    roopajyothi, Jun 29, 2010 IP
  5. rizmy

    rizmy Member

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    Thanxs for your reply
    Above level mean category id is there anyway to send category id without display
    in page url "mobilephones_lvl50.html"
     
    rizmy, Jul 2, 2010 IP
  6. kaviarasankk

    kaviarasankk Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    webmaster-toolkit.com/mod_rewrite-rewriterule-generator

    this site mod rewrite generator
     
    kaviarasankk, Jul 3, 2010 IP
  7. rizmy

    rizmy Member

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #7
    Thanks for all of your helps
    Finaly
    I wrote follow
    "RewriteRule ^level/([^/]*)/([^/]*)\.html$ /browse.html?level=$1&categoryname=$2 [L]"
    Result is http://mysite.com/level/50/mobilephones.html

    Problem is css is not loading :(
    how can i solve that?
     
    rizmy, Jul 3, 2010 IP
  8. kaviarasankk

    kaviarasankk Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yeah its perfect friend you did it
     
    kaviarasankk, Jul 3, 2010 IP
  9. noame

    noame Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #9
    put '/' in front of the path of your css file.
    it make the path become absolute, not relative to the current page.
     
    noame, Jul 4, 2010 IP
  10. kaviarasankk

    kaviarasankk Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    assign an $mainurl = 'http://mysite.com/theme/style.css';


    then include where ever u wanna css this is really easy
     
    kaviarasankk, Jul 4, 2010 IP
  11. rizmy

    rizmy Member

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #11
    Hi
    Above all of replies work fine :) thanks lot !!!
    i want to mask white space when rewriting url. for a example if subcategory name ='Mobile Phones' its should be rewrite as mobile-phones.html
    is it possible?

    FYI
    Currently iam using following method to rewrite
    "RewriteRule ^level/([^/]*)/([^/]*)\.html$ /browse.html?level=$1&categoryname=$2 [L]"
     
    rizmy, Jul 5, 2010 IP