SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL rewrite question

    Hi

    Can somebody help me write htaccess to do the following:

    301 redirect:
    domain1.com.au
    domain2.com.au
    domain-3.net.au
    (anycombo).com.au
    domain1.net.au
    domain2.net.au
    domain-3.net.au
    (anycombo).net.au

    to:
    someotherdomain.com.au?domain=(as above .com.au/.net.au)


    So
    PHP Code:
    http://yadayada.com.au would 301 redirect to
    http://www.someotherdomain.com.au?domain=yadayada.com.au

    http://www.yadayada.com.au would 301 redirect to
    http://www.someotherdomain.com.au?domain=yadayada.com.au

    http://DOMAIN-3.NET.AU would 301 redirect to
    http://www.someotherdomain.com.au?domain=domain-3.net.au 
    Kind of like what cpanel does, but with wildcards:

    RewriteCond %{HTTP_HOST} ^domain\.com\.au$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.com\.au$
    RewriteRule ^/?$ "http\:\/\/www\.otherdomain\.com\.au\?domain\=domain\.com\.au" [R=301,L]

    Thank you!

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

    Are you kidding? This one is just too simple!

    First, I've got to assume that all your domains are colocated in your DocumentRoot (where a single .htaccess file can handle all the redirections).

    Specification: (www.)?domainx.com/net.au => someotherdomain.com.au?domain=domainx with extension but only to the default DirectoryIndex (very poor technique, IMHO, to avoid the filename)

    Easy peasy:

    Code:
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ([a-z]+\.(com|net)\.au)$ [NC]
    RewriteRule .? http://someotherdomain.com.au/?domain=%1 [R=301,L]
    Please note that BB code's [ code ] does not inject all the silly colors of the [ PHP ] brackets.

    You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too. That's the polite way of saying that there's so much wrong with your mod_rewrite as to make me cringe and avoid commenting on it - okay, it's only half bad. Just use the above and you'll be fine.

    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
  •