mod-rewritehttp-status-code-301isapi-rewriteisapi-redirect

Help with redirection for .com, .net and .org domains: redirecting all of them to .com


I need help with some rules in ISAPI_Rewrite in my installation. (If you only know mod_rewrite could be a good help to, so I would adapt the configuration).

I'm going to be very honest about my needs. I need to do this configuration in the next few hours, and don't have time right now understand everything about rewrites, regular expressions and such. I really think you can help me, if I had more reputation I would even set up a bounty... :(

In fact, I believe that what I need is simple:

I have a .com domain. The main url of my website is going to be http:// www.mainurl.com/. I have two other domains: mainurl.net and mainurl.org.

What I need (in isapi-rewrite 2, the config made with httpd.ini file in root file) is: everytime someone writes mainurl.net in browser it becomes http:// www.mainurl.com/ 301 redirect. If it's written without www becomes http:// www.mainurl.com/. If someone writes mainurl.net/about it becomes http:// www.mainurl.com/about/. Redirect always the .com, the www part and the final slash /.

Thanks in advance you all!


Solution

  • Your ISAPI_Rewrite2 syntax will be:

    [ISAPI_Rewrite]
    
    RewriteCond Host: (mailurl\.(?:net|org|com))
    RewriteRule (.*?)(/)? http\://www.$1$2(?3:/) [R]
    
    RewriteCond Host: www\.mainurl\.(?:net|org)
    RewriteRule (.*) http:// www.mainurl.com$1 [RP]