SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL Rewrite rules

    I have never written htaccess rewrite rules before.

    I need this url

    http://mysite.com/view_retailer.php?rid=770

    rewritten to

    http://mysite.com/retailer/{What ever is the title in the rid770 database}

    and this url

    http://mysite.com/retailers.php?cat=39

    to

    http://mysite.com/{the category title that is in the database cat=39}

    Thanks

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,314
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by DigitalEditor View Post
    rewritten to

    http://mysite.com/retailer/{What ever is the title in the rid770 database}
    If your new URLs require a database lookup, then you can't do it with rewrite rules. You'll have to generate the redirect response with PHP.
    "First make it work. Then make it better."

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    RewriteMap WILL do that if you have access to the server or vhosts file. However, because any coding error can bring down the server, you should not attempt this unless you know what you're doing.

    You can do the same thing, though, using a PHP handler file (redirect to the handler thence on to the file you want to serve based on the input). I'd covered this before in this board and it should also be in the tutorial linked in my signature. FWIW, I call it a "Poor Man's RewriteMap."

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •