SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess redirect: help needed

    Hello,

    I urgently need to redirect two specific URLs.

    An online store I've developed uses overly-complicated URLs for the products. However, two of these URLs have had SEO links built for them and I therefore want to re-direct them to the new URL format.

    The old format:
    http://www.mydomain.co.uk/online-sto...e=product-name

    New format:
    http://www.mydomain.co.uk/online-sto...duct.php?id=38

    I know this isn't perfect, but it's the format I want to proceed with for now.

    My attempt at the redirection was this:

    Redirect 301 /online-store/product.php?year=2009&month=06&day=15&title=product-name http://www.mydomain.co.uk/online-sto...duct.php?id=38

    It doesn't work...
    spitfireweb

  2. #2
    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)
    SFW,

    That's what I would have suggested so, if it didn't work for you, then mod_alias can't look at the {QUERY_STRING} variable => you're forced to use mod_rewrite:
    Code:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} year=2009
    RewriteCond %{QUERY_STRING} month=06
    RewriteCond %{QUERY_STRING} day=15
    RewriteCond %{QUERY_STRING} title=product-name
    RewriteRule ^online-store/product\.php http://www.mydomain.co.uk/online-store/product.php?id=38 [R=301,L]
    Please note that I parsed your query string because the order may be different (if not, recombine them with the &'s) - they will AND with the order not being a factor.

    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

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the end I used php to perform a 301 redirect... Hopefully this will be sufficient.

    Many thanks all the same.

    Ben
    spitfireweb


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
  •