Results 1 to 3 of 3
  1. #1
    Full Member
    Join Date
    January 18th, 2005
    Posts
    396
    Need a little help with RegX ...
    I have the following RegX statements in my .htaccess file:


    RewriteEngine ON
    RewriteRule ^([^/]+).htm$ Index.PHP?SKU=$1 [L]

    It takes an URL of the form www.xxxxx.com/uuu-yyyy-z.htm
    and converts it to:
    Index.PHP?SKU=uuu-yyyy-z

    I would like it expanded to convert:
    www.xxxxx.com/dog/cat/uuu-yyy.htm
    into
    Index.PHP?SKU=uuu-yyy

    Help appreciated

    Charles

  2. #2
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    551
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.htm$ index.php?sku=$3 [L]

    I dont see the point though. If your not going to use $1 & $2 then why put them there in the first place?

    Just in case you do want to use them :-

    RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.htm$ index.php?cat0=$1&cat1=$2&sku=$3 [L]

    This will give you

    index.php?cat0=dog&cat1=cat&sku=uuu-yyy

  3. #3
    Full Member
    Join Date
    January 18th, 2005
    Posts
    396
    The reason I wish to have a versatile RewriteRule that yields only the final portion of the URL is because of some mistakes on my part many of my pages got well indexed in deep subdirectories - my present structure is much flatter with all 'pages' located just under the domain - so I am trying to accommodate the older structure

    I changed my original RewriteRule from:

    RewriteRule ^([^/]+).htm$ Index.PHP?SKU=$1 [L]
    to:
    RewriteRule ^.*([^/]+).htm$ Index.PHP?SKU=$1 [L]

    This Rule takes
    :
    www.aaaa.com/dog/catt/rat/xyz-abc.htm OR www.aaaa.com/xyz-abc.htm OR www.aaaa.com/catt/xyz-abc.htm

    however all yield

    Index.PHP?SKU=c rather than Index.PHP?SKU=xyz-abc

    Thoughts?
    Last edited by micheck; February 22nd, 2008 at 03:23 PM. Reason: add 'all yield' rather than 'both yield'

  4. Newsletter Signup

+ Reply to Thread

Posting Permissions

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