.htaccess 301 redirect question

sky11

Registered Member
Joined
Apr 22, 2013
Messages
81
Reaction score
5
Hello,

Google is indexing my domain's dedicated ip and not my actual domain name in some posts.

some days before I have added a non-w w w to w w w 301 redirect.

but now I also want to redirect ip to w w w.

Please advice me how can I do it.

Thanks
 
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on

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

</IfModule>

That should do yeah. I have never has any issue with an IP coming up this way.
 
Last edited:
when you say they are "indexing" your ip, how exactly do you know this? Where does it show?
 
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on

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

</IfModule>

That should do yeah

I think maybe he already has that setup
 
Yes your probably right, but I do not understand the IP part. Never had an issue like that before with .htaccess. Is your DNS configured properly? You can check your DNS resolving at http://www.intodns.com

OP, why would you want to redirect your IP to WWW? Are you forwarding your domain to a WAMP type host with no NameServers?
 
Last edited:
I have already added non-w w w to w w w 301 redirect.
but I also want to add ip to w w w redirect.

want to now that if I want to redirect my ip to my domain then can I type another two lines in the below of the upper mention lines only by changing the first line domain to my ip ?
 
just test it mate, put it in and try
 
Beware of "double content penalization" if your domain is reachable with "www" also
 
Sky,

If you have a redirect set up, you already are redirecting your IP address to another one because a domain name acts as an easy-to-understand wrapper for an IP address. I think you may need to describe your problem a little better for anyone to help you.

When you say your domains?s dedicated IP is being indexed, it is not clear what you mean by that. Are there characters that are showing up in SERP?s that you don?t want to show up? If so, a redirect will not solve this issue. You have to change the source of where Google is pulling that information from (usually from your pages but can come from your host in regards to domain names).

You might be able to find some other ideas in this thread,

http://www.webmasterworld.com/google/4327200.htm

Or here, http://www.searchenginejournal.com/3-ways-to-make-your-serp-listing-stand-out/59961/

Best,

Shawn
 
Last edited:
He is talking about "IP canonicalization"


Here is how you do it:

# Start Ensure www on all URLs and ip canonicalization to same host
RewriteCond %{HTTP_HOST} ^111\.222\.222\.111
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
# End
 
Back
Top