SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    au
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod rewrite regex

    hi,
    i am really a beginner of the mod rewrite thingy. Can any one help me to correct code if i wrote the regex incorrect because it is not working.

    My original URLs are :

    http://www.website.com.au/printingqu...d=stock_intake
    http://www.website.com.au/printingqu...nth=March_2004

    *******************************************************
    I would like to rewrite the URL to :

    www.website.com.au/print/stock_intake
    www.website.com.au /2004-03/March_2004

    ********************************************************
    this is the regex that i wrote in my .htaccess file :

    Options +FollowSymlinks
    RewriteEngine On

    RewriteRule ^print\/(.*)$ /printingquote.php?thread=$1 [L,NC]
    RewriteRule ^(.*)\/(.*)$ /printingquote2.php?thread=$1&month=$2 [L,NC]

    ********************************************************
    What i notice is only URL without parameter is redirecting to other URL :

    www.website.com.au/printingquote1.php

    thanx in advance,
    wxyz

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

    Try:
    Code:
    RewriteEngine On
    
    RewriteRule ^print/([a-zA-Z_]+)$ printingquote.php?thread=$1 [L]
    RewriteRule ^([0-9-]+)/([a-zA-Z0-9_)+)$ printingquote2.php?thread=$1&month=$2 [L]
    It's always best to specify the characters that you DO allow rather than accept EVERYTHING (.*).

    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
  •