views:

50

answers:

1

Hi all! 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!

+1  A: 

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]
TonyCool
I'm still having some problems with mainurl.net/index.html to redirect to mainurl.com/index.html, it becomes mainurl.com/index.html/... I know it's not your fault, my example that was poor... but everything else was working perfectly!! Thanks a lot!!!
Somebody still uses you MS-DOS
I'm checking your answer as accepted it's already a really good one. If it's not asking too much, I would like to fix the problem I described in the last comment... anyways, thanks!!
Somebody still uses you MS-DOS
Please try to fix the config in the following way:[ISAPI_Rewrite]RewriteCond Host: (.*)RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [R]RewriteCond Host: (mailurl\.(?:net|org|com))RewriteRule (.*) http\://www.$1$2 [R]RewriteCond Host: www\.mainurl\.(?:net|org)RewriteRule (.*) http:// www.mainurl.com$1 [RP]
TonyCool