Redirecting from IP address to domian name...

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 4
Joined: 10 Jul 2013, 12:31

Redirecting from IP address to domian name...

10 Jul 2013, 12:35

Hello,


I need to rewrite links coming in with IP address instead of domain name,

from: http://999.999.999.999/product/category/item.aspx
to: http://www.domain.com/product/category/item.aspx

Are there any code samples anywhere for this scenario?
Any one could help with syntax?

Thanks in advance.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting from IP address to domian name...

10 Jul 2013, 20:39

Hello,

Please, try uing the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} ^999\.999\.999\.999$ [NC]
RewriteRule (.*) http://www.domain.com/$1 [NC,R=301,L]


The idea is take from Examples Section under "Moving site location" - http://www.helicontech.com/isapi_rewrit ... amples.htm

Regards
Andrew

User avatar
Posts: 4
Joined: 10 Jul 2013, 12:31

Re: Redirecting from IP address to domian name...

11 Jul 2013, 10:18

Thank you Andrew,

I tried that, but it only works on root folders ;

Will redirect from;
http://999.999.999.999/item.aspx


Will not redirect from;
http://999.999.999.999/product/category/item.aspx

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting from IP address to domian name...

11 Jul 2013, 10:26

Does it keep 999.999.999.999?

Also, the rule is written to redirect ALL requests. If it doesn't, please, inspect your rules and find the one that prevents from redirecting.

Regards
Andrew

User avatar
Posts: 4
Joined: 10 Jul 2013, 12:31

Re: Redirecting from IP address to domian name...

11 Jul 2013, 10:58

Yes it does keep the ip address.

This is the only rule I have.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting from IP address to domian name...

11 Jul 2013, 11:13

This means we are doing something wrong.
Please, try to make logging work and see what rewrite.log says. The logging issues are desribed here - http://www.helicontech.com/forum/10648-FAQ.html

Regards
Andrew

User avatar
Posts: 4
Joined: 10 Jul 2013, 12:31

Re: Redirecting from IP address to domian name...

11 Jul 2013, 12:02

Can I send you a copy of the log?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting from IP address to domian name...

11 Jul 2013, 15:24

Sure, please, use email or helpdesk. And please, specify the reference to this topic.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 10 guests