There is a list of options in my website home page - for example, http://example.com. When a user clicks on option1, I want to show the URL as http://option1.example.com and not http://example.com/xyz.php?opt=option1. Any help or guidance would be appreciated.
You will either need to create a subdomain for each option and then provide the required code at that subdomain. how you set that up varies by hosting provider.
Do you really need a seperate subdomain per option?
Could you use http://abc.ca/Option1/ or http://abc.ca/Options/1/ instead?
If not you will need to contact your hosting providers about creating subdomains option1.abc.ca etc and where to put your php pages.
If you are hosting your own server with apache, I think it is possible to use a * dns entry to accept all subdomains and then you can use $_SERVER variables to get the domain being requested.
Related
I have a site where I am loading country-based dynamic contents. While Laravel's Request::ip() gets the proper(original) client IP if user visits the domain.com version, www.domain.com version gets the same IP for all visitors. I suppose it's the NS resolver server somewhere or something I am not aware of.
Is there a way to set the www version with redirects or something else so that $_SERVER['X-Forwarded-For'] or $_SERVER['HTTP_X_FORWARDED_FOR'] or $_SERVER['REMOTE_ADDR'] gets the original client's IP? It's a Cpanel, so I don't have all the independence on all the DNS components to forward everything as per my need with custom Apache or Nginx setup. I just need a bypass, so to speak, if any.
It is generally a bad setup if you allow clints to access a website with two different URLs i.e. www and non-www. This is because Google sees these as two different websites and logs stats for them separately. This is of course not ideal if you want good SEO. You should re-direct all clients to one URL, choose either www or non-www.
To achieve this you can create a redirect rule in your server configuration files.
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.
I want to redirect (beta.mysite.com) subdomain, which is on another server (I only changed the DNS A record) to my main domain site, but would like to send with parameters like mysite.com?beta=1, and keep the subdomain url like beta.mysite.com.
On the main site I'd like to check the url (with get method) and if it's equal with my conditions I'd change the content with PHP.
Is this possible to do?
Thanks in advance!
You will require a reverse proxy server to do that. Which you can setup on beta.mysite.com and perform the proxy request with additional params.
You can use any of the reverse proxy servers . eg. HAPROXY, nginx etc.
I want to point one domain to another existing domain.
For example I have the following two domains:
test1.com
test2.com
Now suppose I have done hosting for test2.com. But now I want that if I open test1.com, that it should open the same content/pages which are displayed in test2.com. I do not want to redirect from test1.com to test2.com. URL should be same as it is i.e test1.com. Is this possible?
I have cpanel hosting.
Please add an url redirect record from your cpanel.
Record-
First domain will be forwarded to second domain.
You can just add the second domain name as parked from cPanel -> Parked domains. It will achieve what you are trying to do:
https://documentation.cpanel.net/display/ALD/Park+a+Domain
Please note however that if you are running WordPress for example, as it is a URL dependable application, it might rewrite your URL.
To restate the question:
I own the example.com domain name. My actual webhost (courtesy of a friend) is some.site.com.
I'd like people to be able to go to example.com and see some.site.com/example/. The thing is, I only want the URL bar to show example.com/whateverpage.html.
I've been studying and experimenting with mod_rewrite, but can't quite figure it out. Is this at all possible?
You could just host a basic web page with an iframe. How complicated is the site?
Who provides your dns - sometimes they have a web forwarding setting just for this.
And are you sure you can't just change the domain name on the site you are pulling from?
You need a CNAME record in your DNS that aliases some.site.com as example.com.
http://en.wikipedia.org/wiki/CNAME_record
If you or your friend don't have access to, or don't know how to modify the DNS server... Contact the HOSTING PROVIDER that is hosting the site, they should know how to make DNS CNAME records correctly. The wiki above has a few examples of what a CNAME record looks like.