Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 8 of 8

This is a discussion on Rewriting IP address to server name in the Shared & Semi-Dedicated forum
How can I use mod_rewrite in order to make sure that if my site is accessed via IP it will rewrite it to domain name? ...

  1. #1
    JPC Addict randyriegel's Avatar
    Join Date
    Jan 2002
    Location
    Wintersville, OH
    Posts
    161

    Rewriting IP address to server name

    How can I use mod_rewrite in order to make sure that if my site is accessed via IP it will rewrite it to domain name? I'm not very familiar with mod_rewrite but I'm assuming this is what I'd use to do this. Example:

    User types:

    69.73.xxx.xxx

    in browser, I want it rewritten to show:

    mydomain.com

    ? I've did search for this and didn't see anything. It's not really an issue and not that important, I'm just curious on how to do it.

    Randy

  2. #2
    Old Hillbilly Connie's Avatar
    Join Date
    Sep 2001
    Location
    Hills of Missouri
    Posts
    2,648
    I think the reason you don't see a solution is because it is not a problem, unless you have incoming links using the IP address.

    What you do need to worry about is domain.com and www.domain.com resolving to the same webpage.

    In this case you do need to use mod_rewrite to direct one to the other.

    Forum Moderators - Jag Staff

    Spam Whackers Blog - Dedicated to fighting Spam and providing General SEO Tips
    Organize your Kitchen or purchase Kitchen Accessories at Condells
    Ihelpyou Forum - Dedicated to "Best Practices" SEO

  3. #3
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,307
    Google very quickly picked up on my IP addy during my server transition last year, indexed the IP based URLs and duplicate penalized some of my canonical pages.

    They (the IP based URLs, all 36,300 of them) are NOW nicely labeled as "Supplemental Results", but that required judicial use of the URL removal tool. After 6 months of being out of the SERPs, they now (again) sometimes appear for phrase searches, unless I again use the removal tool. What a hassle.

  4. #4
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,307
    ...and using mod_rewrite, he could very easily redirect ###.###.###.### (the specific IP addy for your site) to www.domain.com, just as easily as redirecting domain.com to www.domain.com.

  5. #5
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,775
    Quote Originally Posted by randyriegel
    How can I use mod_rewrite in order to make sure that if my site is accessed via IP it will rewrite it to domain name?
    I suggest using a redirect. IPs change from time-to-time. For instance, I've had three 'static' IPs (on the same account) since I've been here... the original IP, once when JagPC changed providers, and once when I changed servers.

    Code:
    RewriteCond %{HTTP_HOST} ^69.69.69.69$
    RewriteRule ^(.*)$ http://example.com/$1  [R=301,L]
    Um, you do have a 'dedicated' IP, or whatever, right?
    Last edited by Vin DSL; 04-13-2006 at 12:27 AM.
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL © 2010

  6. #6
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,307
    If not, would the code look like this:
    Code:
    RewriteCond %{HTTP_HOST} ^69.69.69.69/~jagaccountname$
    RewriteRule ^(.*)$ http://example.com/$1  [R=301,L]
    ??

  7. #7
    JPC Addict randyriegel's Avatar
    Join Date
    Jan 2002
    Location
    Wintersville, OH
    Posts
    161
    Yes, I have a static IP. The redirect works perfect.
    Thanks,
    Randy

  8. #8
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Quote Originally Posted by Ron
    If not, would the code look like this:
    Code:
    RewriteCond %{HTTP_HOST} ^69.69.69.69/~jagaccountname$
    RewriteRule ^(.*)$ http://example.com/$1  [R=301,L]
    ??
    Not quite. HTTP_HOST only contains the host name (or in this case, the IP address). In the case of a non-dedicated IP you'd want to use something like this:

    Code:
    RewriteCond %{HTTP_HOST} ^69.69.69.69$
    RewriteRule ^~jaguaraccountname/(.*)$ http://example.com/$1 [R=301,L]
    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •