Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
Is it possible to redirect a group of IP addresses to a https version of a website? As far as my website is concerned, it's running on http. I've noticed ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2014
    Posts
    9

    Can I redirect a group of IP to https ?


    Is it possible to redirect a group of IP addresses to a https version of a website?

    As far as my website is concerned, it's running on http.
    I've noticed that some ISPs inject their own codes or advertisements, via javascript on their customers.

    My websites displays normally on some ISP but looks modified on other ISP due to the javascript injection done on the ISPs side.

    I did some experiment on the said ISP, they indeed insert a javascript on normal http site but doesn't or can't insert their code on a https site.

    Is it possible to redirect a specific ISP or group of IP addresses to an https site while all others defaulted to http one.

    I can't use https for all as I have already spent money for SEO on http one.

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,193
    You haven't said anything about your web stack but yes, you can redirect to https - a 301 header can be used - and selecting for a range of addresses is generally trivial.

  3. #3
    Just Joined!
    Join Date
    Jan 2014
    Posts
    9
    Quote Originally Posted by gregm View Post
    You haven't said anything about your web stack but yes, you can redirect to https - a 301 header can be used - and selecting for a range of addresses is generally trivial.
    Do you have a guide or a link on how to do just that? By the way, my website is hosted on a shared web hosting account.
    Website is written on PHP. I mainly used redirection via .htaccess

    Thanks.
    Last edited by Siquijor; 01-04-2014 at 05:06 AM. Reason: Added more information.

  4. #4
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,193
    Since you're using apaches mod_rewrite you can look up RewriteCond REMOTE_ADDR. Add the range of addresses you wish to redirect.

    ie.
    Code:
    RewriteCond %{REMOTE_ADDR} ^(192\.168\.0\.*)$
    RewriteRule ^/* https://www.your_domain.com/ [R=301]
    I'm sure you can find the specifics in Apache's documentation for mod_rewrite.

  5. #5
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,879
    Just to be clear - you're not forwarding whole IP addresses to the https port - what you're doing is forwarding http connections on one (or more) IP address to https connection on another IP address.

    The way I do this is with this incantation in my httpd.conf for the website I redirect:

    Code:
    RedirectMatch permanent ^/(.*) https://my.website.net/$1
    Obviously I use my real domain name in this. I also have this in a VirtualHost declaration for the website I'm diverting - and that's the key, you're doing this on a website by website basis, not an IP by IP basis, but if the websites are on different IP addresses you can put this safely into your main httpd.conf.

    You -can- also do this with a bit of html in the web page you're forwarding the connection from, something like this in the <head> node:

    Code:
    <meta http-equiv="refresh" content="0; url=https://my.website.net/index.html">
    Linux user #126863 - see http://linuxcounter.net/

  6. #6
    Just Joined!
    Join Date
    Jan 2014
    Posts
    9
    @Roxoff
    I just want to redirect a group of IP addresses, range of IP addresses used by a specific ISP, to the https version of my website.

    Based on your code above, especially the 2nd code, that is used to redirect from one domain to another via html. I'm using that on code on my new domain, .net, to redirect to .com via html.

  7. #7
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,879
    Quote Originally Posted by Siquijor View Post
    @Roxoff
    I just want to redirect a group of IP addresses, range of IP addresses used by a specific ISP, to the https version of my website.

    Based on your code above, especially the 2nd code, that is used to redirect from one domain to another via html. I'm using that on code on my new domain, .net, to redirect to .com via html.
    You should be doing this on a per-website basis if you can. The HTML header way or through Apache's .conf file shouldn't affect your SEO - people will still connect to your http address and land at your https address. A permanent redirect will even help here, because a returning client browser will intercept the call, know that there is a permanent redirect in place and automatically use the new target.

    The only other suggestion I have is that, if you have an ISP that's doing Javascript injection when serving up your pages, then it's time to move to an ISP that will actually allow its customers to behave like grown ups and not dump all over their Javascript.

    The SEO stuff is usually done by domain name anyway, isn't it, not by the IP address? Surely if you just point your old domains at different IP addresses, all your SEO work will still be valid?
    Linux user #126863 - see http://linuxcounter.net/

  8. #8
    Just Joined! KenWeiLL's Avatar
    Join Date
    Jan 2014
    Location
    Philippines
    Posts
    10
    Quote Originally Posted by Roxoff View Post
    The only other suggestion I have is that, if you have an ISP that's doing Javascript injection when serving up your pages, then it's time to move to an ISP that will actually allow its customers to behave like grown ups and not dump all over their Javascript.
    I'm also from the Philippines, particularly from Siquijor (island), most ISPs actually do javascript injection on their customers browsing activities. These scripts displays advertisement about the ISPs promos. Others are used to display a toolbar, a popup toolbar actually, which allows customers to view their load balance (for mobile users).

    Changing ISP is not an option.

    I also have a website, it works normally when I'm browsing on my laptop using SmartBro connection in particular, no injection is happening.
    But if I browse my website using Globe internet connection, particularly via their mobile internet on my phone, use tethering to share the connection from phone to my laptop, my website's style gets "damage". I mean, it looks different compared to browsing from the other ISP. Upon checking the source code, I see a javascript embedded before </body> tag. It's a toolbar, or a "fake toolbar" from Globe.

    Opening Facebook via Globe, it works normal. Probably they can't inject their code on https sites? My website is an http site, not an https site.

    His/her problem, Siquijor, it not that of his browsing experience. My problem is not on my browsing experience, but on my customers or visitors viewing my website which they connect via Globe. They, usually, PM me on Facebook as to what happened to my website, a huge white space is displayed at the bottom of my website. I can't tell them to switch ISP just because of that.

    Me and Siquijor have a common problem. Or website's visitor, connecting from Globe mobile is having problem browsing our website because of the code injection.

    Last month, I actually contacted Globe about their injection and until now, it's still active. I've done some Googling about it and found out that it was also reported about 6 months ago. I contacted Globe again about the report and they said, "yes, it was reported by [some user], 5 months ago and their IT team is doing their best to resolve that issue. I told them, "5 months and still your IT team is still working on it?" then after than, they no longer replied to my messages.

    I now someone working on Globe Telecom, and asked him about it but it seems like he's trying to abort the issue. Probably, he can't do anything about it.

    The best way for Siquijor and me is to revert to an https site to avoid injection. It seems like they can only inject or they only inject codes on non-https sites.
    Currently on my web host, Namecheap, there's no such thing as free ssl certificate (HostGator has) and is the reason why until now, I'm stucked on http site. I can't afford purchasing a ssl certificate.

    Quote Originally Posted by Roxoff View Post
    The SEO stuff is usually done by domain name anyway, isn't it, not by the IP address? Surely if you just point your old domains at different IP addresses, all your SEO work will still be valid?
    It's usually done by domain name. I'm not sure with IP address, but some said that IP address matters. For example, your website is on a shared hosting, meaning, a lot of other websites are hosting under the same hosting, and if one of those websites are spammed, there's also a chance that the search engine will also mark your domain as spam as both your website and the spammed website is under the same IP address.

    But I don't actually know if it's true. It's just a theory.
    Some SEO guys always recommend to use or purchase a private (or not shared) IP address for my website. That way, you're the only one or your domain is the only domain associted with that IP address.

  9. #9
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,879
    I'll admit upfront that I'm far from any kind of expert on SEO. But search engines are going to categorize by domain name, surely, as IP addresses can (and do) change from time to time - my own static IPs changed only a fortnight ago when I moved ISP for better bandwidth. My website logs still show the same attempts to access the same domain with the same sub-pages by the search boys...

    With that in mind, then perhaps the best solution would be to try and host your website somewhere else, somewhere other than in the Philippines? If you had a host and an IP address in another territory, then others could connect, and only accesses from inside the Philippines would suffer from any kind of injection?
    Linux user #126863 - see http://linuxcounter.net/

  10. #10
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,193
    Quote Originally Posted by KenWeiLL View Post

    The best way for Siquijor and me is to revert to an https site to avoid injection. It seems like they can only inject or they only inject codes on non-https sites.
    Currently on my web host, Namecheap, there's no such thing as free ssl certificate (HostGator has) and is the reason why until now, I'm stucked on http site. I can't afford purchasing a ssl certificate.

    A couple of thoughts. TLS (SSL - HTTPS) does prevent that sort of thing. It isn't necessary to use a correctly signed certificate to prevent injection. The certificate signing provides another aspect of security - confidence in the source - but since you're not necessarily concerned with that a self-signed certificate may work for you.

    https://jamielinux.com/articles/2013...ate-authority/

    Of course this depends on whether the people accessing your site choose to trust you.

Page 1 of 2 1 2 LastLast

Posting Permissions

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