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

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} [1]domain[/B]\.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!


  1. B ↩︎

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:

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