SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL redirect problem using Htaccess

    Hi,

    I cannot post to the forum due to my post containing links, even after having removed them. Please see the attached txt file which explains the problem I am having trying to migrate URLs.

    Thanks in advance for any help.

    Cheers,
    Tim
    Attached Files Attached Files

  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)
    TP,

    First, welcome!
    Quote Originally Posted by TP
    I am having a nightmare trying to work out how to permanently redirect (301) my URL’s using htaccess rewrites in order to migrate a site.

    I want to do the redirect based on the A variable, and ignore everything after it, the reason being because the URLs currently have different Z variables, but the URL doesn't contain a page name. The second variable is not relevant and can be ignored. For example:

    I want both these URLs which contain a=1204:
    http://www.xyz.com/en/?a=1204&z=1
    http://www.xyz.com/en/?a=1204&z=99

    To permanently redirect to:
    http://www.xyz.com/london/

    And, for these URL’s containing a=99:
    http://www.xyz.com/en/?a=99&z=3
    http://www.xyz.com/en/?a=99&z=41

    To permanently redirect to:
    http://www.xyz.com/chicago/

    I’ve tried a huge array of different RewriteRule and RewriteCond combinations and am having no luck. Please could someone explain how I would do this as I need to migrate them.

    I can get most of my other urls migrated when a page name is present by using the rule below, but not those in the example above.

    Code:
    RewriteCond %{QUERY_STRING} a=99
    RewriteRule ^listing.aspx$ http://www.xyz.com/london? [R=301]
    From your examples, listing.aspx causes some concern. There is no listing.aspx in your example http://www.xyz.com/en/?a=99&z=3. HOW did that get into the URI?

    Moreover problematic, are you using Apache as your server (not some IIS version which can mimic mod_rewrite)?

    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
  •