Redirecting using Htaccess

Discussion in 'Apache' started by ridesign, Jun 17, 2009.

  1. #1
    I have a page http://www.site.com/new

    1)I want to redirect http://www.site.com/new/1/
    to : http://www.site.com/new?pg=1

    2)And redirect http://www.site.com/new/cat/2/
    to : http://www.site.com/new?c=cat&pg=2

    3)And redirect http://www.site.com/new/cat/
    to : http://www.site.com/new?c=cat

    I have attempted the following 1 and 2 work but 3 does not work:
    "c" will always be small letters and "pg" will be between 1-5.

    
    RewriteRule ^new/([a-z])/$ /new/?c=$1 [L]
    RewriteRule ^new/(.*)/([0-9])/$ /new/?c=$1&pg=$2 [L]
    RewriteRule ^new/([0-9])/$ /new/?pg=$1 [L]
    
    Code (markup):
     
    ridesign, Jun 17, 2009 IP