So I setup a subdomain off my regular domain. I then make an A record on Cloudflare to point to the IP address of my server. However, whenever I go to the subdomain, it just takes me back to the main hostname. (So i have sub.domain.com and when I go to sub.domain.com in my browser, it redirects me back to domain.com)
What could be the issue? I've checked .htaccess.
I've had similar issues with cPanel and Cloudflare before where cloudflare won't properly direct to the proper subdomain.
This is very difficult to look at without knowing the actual domain or subdomain in question. We don't do anything that would put a redirect in by default, so it sounds like it may be an issue on your server directly.
Related
I have two domains with GoDaddy: foo.com and bar.com
I want to redirect foo.com to bar.com/foo
I tried setting up Domain Forwarding from within the GoDaddy Dashboard and it did work, but not for HTTPS (which is the URL indexed within Google).
I checked with GoDaddy Support and received this response:
That will not work because your domain does not have an SSL Certificate active and there is no way to activate an SSL Certificate on it with a forward.
Maybe I'm overthinking this, but here's an alternative approach I had in mind:
Set the A record of foo.com to the same IP address that bar.com is using
Within the website code of bar.com, check the $_SERVER['SERVER_NAME'] and redirect appropriately
By using plain DNS this is not possible, the reason for this is that DNS is a protocol different than HTTP.
Some providers offer "forwarding" options but behind the scenes, they point your domain to an HTTP server the one later does the redirect.
For example, using CloudFlare this could be very easy to achieve, you need to setup up only one domain, let's say foo.com and then just create a page rule to redirect traffic to bar.com/foo, the rule could be something like:
*foo.com*
More info about the page rules can be found here: https://support.cloudflare.com/hc/en-us/articles/200168306-Is-there-a-tutorial-for-Page-Rules-
I have a Debian server which is running a number of client sites. Most of these are not running SSL so accessing by HTTP is fine.
I have one customer with an SSL certificate and accessing their site via HTTPS is fine too.
The problem comes if you try to access one of the other sites with HTTPS you get directed to the other site that has the SSL certificate.
For instance, lets say we have the following sites on the server:
alpha.net
bravo.net
charlie.net (SSL)
delta.net
So as you can see, charlie is the only one with SSL, and irrespective of if you go to http charlie.net or https charlie.net, it works fine.
http to all the other sites is fine, but if you were to go to https alpha.net, it will initially come up with an Invalid Certificate error and let you continue but whilst it has alpha.net in the address bar, its actually showing the charlie.net site in the browser.
I have researched SNI and how if any other sites have SSL I'll need to put them all on specific IP addresses (something else I need to try to work out how to do as I have no idea) but I am not sure why this is happening or how I resolve it.
Has anyone else encountered this before and how did you get around it?
Many thanks,
Rob
This does not have anything to do with SNI, as you currently only have one HTTPS server. What happens, as you've stated in your comment, is that the alpha.net domain resolves to your server's IP. Your Apache server is set up to listen for requests on port 443 on this IP, and to serve the contents of charlie.net to these requests. (And the certificate error means that the browser noticed the discrepancy between the certificate's alleged domain name and the domain name used for the request.)
Redirecting from HTTPS to HTTP is probably more trouble that it's worth, since you would need valid certificates for each domain, lest you present your users with another security warning. This would entail creating virtual hosts for alpha.net:443 and so on, on an SNI capable server (i.e., later versions of Apache 2.2+ with openssl), and adding a redirection like so:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
Probably the easiest course for your problem is to use a different IP for charlie.net. With this setup, there would be no way for alpha.net (and so on) to display the contents of another site.
If you have multiple IPs on your server, use a unique one for the SSL site, all non-SSL sites share another IP.
Since SSL doesn't care what is the domain you are visiting, it only cares if the current domain is approved from the list of domains(Common Name) it gets from the Ip address.
I have been using apache server. I want to redirect some URL to another, eg. www.abc.com to localhost:8080/Home
I uncommented rewrite module in httpd.conf in conf folder of apache installation. Then I wrote rewrite rule like show below in httpd.conf file.
RewriteEngine On # Turn on the rewriting engine
RewriteRule http://www.abc.com http://localhost:8080/Home/
But nothing happened. It is simply opening abc.com as normal. There is no error message not even in log.
Can anyone suggest where the problem is?
You can only rewrite URLs that have the server as a host. Since you do not host www.abc.com, you cannot rewrite any of its URLs.
It's not the 'best' solution, but I use it at home.
Edit the 'hosts' file on your own PC to redirect. For example, mine redirects 'attic' to ip 10.0.0.5, my server in the attic. So when I type attic/myfolder, I get what I would normally get at 10.0.0.5/myfolder.
Your hosts default location can be found with a very quick google.
Not the best, as I say, but it works.
EDIT:
Okay, something.something, we'll call it xyz.com.
We need 2 things here;
a) your server must expect traffic from xyz.com
(this is just a config on the server, easy to achieve).
b) your browser must be pointed to your server when you type xyz.com.
Normally, when you type xyz.com into any browser, your PC will connect to a DNS server to find out where in the world xyz.com actually is (the DNS server returns an IP address). To inform the DNS servers that xyz.com should point to YOUR server, you need to pay to register the domain name with a registrar (unassigned domains aren't expensive). This is the best way, as every computer will now know how to get to your server by typing xyz.com. When you move your website to a hosted server, you go to your registrar's website and change the settings, saying "stop pointing to the IP of my home server and start poionting to the IP of my hosted server".
Or, if you don't want to do that, you need to tell YOUR PC to skip the DNS check, and you do that by modifying your hosts file as above. This will only work for you, but is enough for home testing purposes.
The third option is running your own DNS server, and manually telling it to override the world-wide settings for xyz.com. That way your browser would get your custom result when it checks the DNS server, and forward straight to your server. However, running your own DNS server is a complex undertaking, and is overkill for your current task.
In summary, from best option to worst:
1) Register your domain and point it home
2) Modify your hosts file to bypass DNS checking
3) Run your own DNS server, and override the settings for xyz.com
Hope I've been more clear this time :O)
I have a website on a subdomain, and would like to hide the fact that it's a sub-domain. How can I do so?
For example, the site is www.example.com, and it's a sub-domain of www.mydomain.com. I don't want people to know that example.mydomain.com is the same as www.example.com. How do I hide this? With .htaccess? How?
Thanks!!
www.example.com is impossible to be a sub-domain of www.mydomain.com. I think you mean they point to the same IP address and, therefore, they point to the same website (or there are some kind of redirect).
A domain is simply, example.com or mydomain.com. Examples of sub-domains of these domains are: www.example.com, mobile.example.com, whatever.mydomain.com and they could, or not, point to the domain root.
I'll present you an example:
Google App Engine let's you chose a appspot.com subdomain, for instance, myapp.appspot.com. If you call this subdomain you access your website. But people usually want to use their own domain, or a subdomain, for instance, myapp.mydomain.com. Both subdomains will return the same content. If you'd wish to disable the appspot.com subdomain, you may follow this solution.
You could use the 'proxy|P' (force proxy) flag.
Read the manual http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Note: mod_proxy must be enabled in order to use this flag.
I'm trying to redirect all subdomain requests for domain.com to www.domain.com even when the subdomain does not exist, for example if we have:
abc.domain.com to www.domain.com
Where abc can be any requests. Furthermore, that subdomain abc may be exists or not. But whatever it is, I want to redirect it to main domain.
And less important request is. How it is possible to keep the input address at the address bar and redirect to main domain?
It will be best for me if it is done by .htaccess
I use apache server.
Thank you.
Since you haven't specified the environment you use, here are some general tips:
First, there is a difference between redirecting:
The user types sub.domain.com into the browser's address bar, but is redirected to domain.com -> domain.com is in the address bar, as the user is now on domain.com
...and rewriting an URL in the background:
The user types in sub.domain.com and stays at this address. The user sees sub.domain.com but in the background some other page (in your case, that one under domain.com) is loaded and shown.
(Quickly explained.)
If you are using Apache, take a look at 301 redirects and url rewriting.
In addition to what Piedone said (which is on the HTTP server side), you also need to configure the DNS to have a catch-all for all subdomains, directing them all to your HTTP server.
This implicitly means that all possible subdomains will exist automatically.