SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod rewrite help

    Hi,

    I want to redirect this url- http://mysite.com/glitter1/animals/d...litterid=dogs1

    to this url-
    http://mysite.com/glitter1/getcode.p...litterid=dogs1

    Which redirect rule should I use?

    Thanks!

  2. #2
    SitePoint Addict pentium10's Avatar
    Join Date
    Apr 2004
    Location
    Transilvania
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteRule ^glitter1/([a-zA-Z0-9äöüÄÖÜ -_]*)/([a-zA-Z0-9äöüÄÖÜ -_]*)/code.php?glitterid=([a-zA-Z0-9äöüÄÖÜ -_]*)$ glitter1/getcode.php?root=$1&cat=$2&glitterid=$3 [L]
    Rype :: book, do, charge, collect,
    track time, track expenses and invoice easily on the go.
    Available on Mac, Win, iPhone, WinMobile.
    http://www.rypenow.com

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    nis,

    First (and foremost), WELCOME to SitePoint and to the Apache Forum!

    You might benefit from a read of the tutorial article in my signature - as would p10 because he does not understand that you can only access query strings from a RewriteCond statement (nor regex!).

    Try:
    Code:
    # .htaccess in DocumentRoot
    RewriteEngine on
    RewriteRule ^/?glitter1/([a-z]+)/([a-z]+)/code\.php$ glitter1/getcode.php?root=$1&cat=$2 [QSA,L]
    I have assumed from your code that you are only using lowercase letters in your values for root and cat and that the glitterid key is already in the query string (which is appended by the QSA flag).

    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

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much. That was great!!! Did the trick!!!!

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I tried using what pentium10 has suggested. But that did not work.


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
  •