Different pages related to website ip address - apache

My website is assigned a particular ip address.
Now, is there any way to configure web server like apache so that when I enter the website url in a browser, it shows a different page than when I enter the ip address related to the website?

Yes. What you're looking for is apache Virtual Hosts.
You'll also need to configure your domain to point to your ip.

Related

moodle gets into 'endless redirection' when configured as subdomain

I'd like to setup my moodle instance to be available by address: http://mymoodle.mysite.com.
mysite.com is already registered and I can easily access it because I've configured it at my hosting provider to refer to the IP (let's say IP address x.x.x.x) of my server where I store my web page.
To register the subdomain I'm specifying another IP address where my moodle instance is installed (e.g. y.y.y.y) and configure my provider to do permanent redirect to the URL http://y.y.y.y
moodle instance is installed at wwwroot folder of the web sever, it's accessible via http://y.y.y.y
Now it works for me in the following way: I type http://mymoodle.mysite.com in address bar of my browser and it redirects me to my moodle instance, I see a main screen, all works fine but the URL in address bar is changed to http://y.y.y.y
Alhtough I'd like to see my fancy subdomain address but not IP.
My config.php originally looks like that
$CFG->wwwroot = 'http://y.y.y.y';
but if I change it to
$CFG->wwwroot = 'http://mymoodle.mysite.com';
I'm getting into 'endless redirects'.
Is there a way to resolve this issue and get rid of IP address in address bar?
If you have changed the url of Moodle after the set-up you have to follow those steps : https://docs.moodle.org/310/en/Moodle_migration. Only updating $CFG->wwwroot will not be ok.

Is there a way to way to control which CNAME gets what content?

My ultimate goal is to have free plan cname content, and premium plan cname content.
For example if someone has a cname of free.example.com set to my website I'd like to show them a specific page, and if premium.example.com I want to show them another page. Finally, I'd like to know if there is a way to add new cnames to my list so that I can have them view a certain page?
Just to make this more understandable this, I want to do something like https://www.gitbook.com/ do with their cnames, and cname serving.
You'll have to use the Host header from the user's request to identify which subdomain or cname they're visiting, and then showing them the desired content. If the subdomain such as free and premium are fixed, you could use Nginx server blocks or Apache virtual hosts to direct the user to specific application or application URI.
Likewise, you can get the Host header with req.hostname in Express. Based on the host, you can route the user to the desired content. You can add as much subdomains or cnames you wish and let your application control the content for the user based on the host. If your DNS host has an API (such as Cloudflare), you can add your subdomains programmatically, or you could do a wildcard subdomain to accept any subdomain.

Should I allow viewing my website by entering the IP in url bar

Should I allow viewing my website by entering the IP in url bar? that means that instead of writing site.com in the browser, I write the IP of the website.
Example:
this IP 85.17.159.246 is not accessible if you put it in the browser bar. But the website hosted by it azlyrics.com is available.
Google on the hand allows viewing its website via direct IP, for example if you use 64.233.165.190 in your browser it will show Google's website.
Is it bad to allow that? Is it good? Why?
In the past I've read that it is not a good idea to allow this, but now I really don't know how to search for this, as all the results on Google return with irrlevant pages.
If it is not a good idea, how can I block it? (without blocking the website url, of course)
We do have domain names for a reason, it brings several nice benefits as being able to move your site to a new IP but keeping the same domain name. Also when using domain names you can have multiple websites on a single IP.
It's not bad. But an IP can only "host" one site. This works for Google, since they'd only be serving up google.com content anyways. But consider a shared server with (say) 50 different sites on it.
When you punch in http://example.com, your browser will hit example.com's IP and include a Host: example.com in the request's HTTP headers. That lets the server identify which of its sites you're requesting.
But if you hit the server's IP directly, there's no Host: header, and now Apache has no idea which of the sites you really want.

front end application user can access the website from specific IP address

front end application ( php / .net / Java ) one user can access the website from specific IP address only, that same user can not access the website from other IP address. How to do this. is this possible?.
You can use the mod_authz_hosts module in Apache to restrict which IP addresses are allowed to access certain sections of the website. Looking through the documentation for the module, you create a .htaccess file in the directory that you want to restrict access and within the file enter details of the allowed IP addresses. For example
Allow from 10.1.2.3
Take a look at the documentation on the documentation for the module which is available at http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html

Can a Facebook App for remote login be identified with IP instead of domain name?

I have a list of sites running on the same server, so they all share the same IP address. a facebook app was created in order to have login functionality on the sites, but as I see, the app needs one and only domain (for security reasons...) that is enabled to use the login process.
Is there a way to identify remote sites with IP instead of one domain name?
Thanks!
No, you must use a domain name, you can enter multiple domain names though, or run the logins through login.yoursites.com or something like that