simply replace domain extension

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 6
Joined: 01 Aug 2012, 08:44

simply replace domain extension

03 Aug 2012, 11:10

Hi,

I'm looking to create a rule that simply replaces the domain extension in a URL (.com) with another (.net), leaving everything else in place. The problem I'm having is the domain could be anything (there are many domains and subdomains pointing at the site and more could be added at any point) that may or may not have a path or querystring so it's not possible to hard code in the domain names.

Basically what I believe I need is a rule that does something like a standard string replace: Replace(url,'.com','.net') so everything else in the URL remains untouched.

Is this possible?

Thanks

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: simply replace domain extension

03 Aug 2012, 11:44

Hello,

I believe it will be possible with the following rule:

RewriteCond %{HTTP_HOST} ^(.*)\.com$ [NC]
RewriteRule .? http\://%1.net%{REQUEST_URI} [R=301,L]

User avatar
Posts: 6
Joined: 01 Aug 2012, 08:44

Re: simply replace domain extension

03 Aug 2012, 12:05

Thanks Anton, works perfectly

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 10 guests