Subdomain wildcard redirect - wordpress

I'm running a minor WordPress (multisite/network) site, on a server using cPanel. The site used to have a lot of subdomains like:
shop.example.com
cars.example.com
music.example.com
and so on...
The problem:
Most of the subdomains are no longer available (neither in the DNS nor anywhere else) - so when you try to reach shop.example.com it just hits a 404.
So my question is:
How do I get all subdomains to redirect to example.com?
What have i done/tried already:
DNS a *.example.com record pointing to the correct IP
DNS CNAME *.example.com record pointing to example.com
Doing this forced it onto the server, so its no longer just a 404, but the server doesn't recognize shop.example.com
Tried messing with subdomains/domain in cPanel (creating a *.example.com), and a couple of other different things
Tried different redirects in cPanel
So what am I doing wrong? I'm pretty sure I need to do a combination of setting up a wildcard DNS record, and doing something in CPanel :P - but I just can't figure out exactly what.

From your post
Doing this forced it onto the server, so its no longer just a 404, but
the server doesn't recognize shop.example.com
You then need to do a 301 Redirect from shop.example.com to wherever you want to go, you can do this is in the CPanel. You will have to do this for each subdomain that that once existed therefore handling any requests that might come.
Unfortunately, there isn't a way to use the wildcard like you can for the IP. Each subdomain is a separate website as far as the webserver software, such as Apache, is concerned. So when you do a redirect you are answering the webserver software question, "OK, I got a HTTP GET request for shop.example.com, what files do I serve up? "
See this section in the CPanel docs for more information on redirecting.

Related

Redirecting HTTP traffic to HTTPS in EC2 hosted web server using cloudfront

Current Scenario
I am hosting a wordpress website on a ECS instance which runs wordpress in a docker container
My wordpress is working fine but i want to change HTTP to HTTPS
What i dont want to use
1) ELB
2) Anything cost ineffective
What i tried
I tried using cloud front and setting ec2-52-64-xxx-xxx.ap-southeast-2.compute.amazonaws.com as origin domain and origin id
I also set it to redirect HTTP to HTTPS
Current CloudFront behaviour
What happens is when i goto the cloudfront link it redirects me to ec2-52-64-xxx-xxx.ap-southeast-2.compute.amazonaws.com (HTTP) instead of using the cloudfront link
Desired CloudFront behaviour
It should use the HTTPS cloudfront URL to use my wordpress website by redirecting any traffic from my origin from HTTP to HTTPS
Current Server configs
1) I don't have any SSL/TLS certificate installed in my ECS instance
2) My .htaccess file has default values (not sure if i even should update it or cloudfront will work without any changes to .htaccess)
3) Wordpress is not installed so the database does not have any values which might be causing a redirect ( I deleted the database to test if that might be causing the inconsistency)
I am really new to AWS,There might be a better way to achieve HTTP to HTTPS redirect i think any sugggestions/help is highly appreciated thanks :)

Domain with www on different IP than non-www

I'm doing my best to learn and understand how DNS works. On my journey, I found something interesting. I've seen several cases, including chanel.com and prada.com, where the website redirects from domain.com to www.domain.com. That's understandable and I've explored this debatable subject in the past. What's new though is that in these cases, the www version is on another IP. So if we open the chanel.com, it makes a 301 redirection to www.chanel.com, which happens to have different IP. What are the potential benefits and reasons of this idea?
A lot of companies have seperate servers or applications to handle redirects, so the real website is only listening to www.example.com and the domain example.com is pointing to the redirect server who is giving the redirect.
This is useful for managing all your redirects in one place, for example you got the domain www.example2.com that should redirect to www.example.com you can handle that easily on the same server. and even redirect to a specific page like www.example.com/example2
Cheers!

Godaddy URL redirect from HTTP to HTTPS

I host my website on heroku and bought the domain from godaddy, here's how I set my DNS records
Records
A - # - Forwaded - 600 secs
CNAME - www - example.com.herokudns.com - 1 Hour
Forwarding
-- Domain --
Redirect to https://www.example.com
-- Subdomain --
example.com Redirect to https://www.example.com
www.example.com Redirect to https://www.example.com
Expected Behaviour
When I enter example.com or www.example.com, it should redirect to https://www.example.com
Result
Only example.com got redirected to https://www.example.com, www.example.com does not
What went wrong with my configuration ?
You can't have www as a CNAME and also www as a redirect. If you have the www CNAME aliased to example.com.herokudns.com it's going to go directly to your app on Heroku and make a connection. Your app must be the one to force the redirect to https at that point. I don't know what language you are using, but if it's Rails then set config.force_ssl = true in production.rb.
If your domain is pointing at Heroku with an A and a CNAME record, then the "forwarding" settings on GoDaddy will have no effect. To implement forwarding, GoDaddy points the domain to their own servers.
Once you point the domain at Heroku, all HTTP to HTTPS redirects have to be implemented at Heroku. You can no longer use Godaddy's forwarding. In any case, GoDaddy's URL forwarding is badly implemented and unreliable. You should never use it. See GoDaddy's 301 redirect/forwarding has some weird random middleman URL, kills link juice?
How to redirect HTTP to HTTPS at Herouku depends on what programming language you use. Basically, the redirect rule has to be programmed into your application. See their documentation for specific instructions for a variety of cases: Can Heroku force an application to use SSL/TLS? - Heroku Help
To actually use the Domain as the Web Address:
The A Record should be the IP Address
The CNAME only needs to be name: www value: #
Also I like to keep the TTL the same for the A and CNAME records.
Wait about an hour before testing to ensure the servers have propagated.
For Domain forwarding you only need to scroll down to Forwarding and select https or http (make sure that is correct). Then the web address/url to the home page.
Use a permanent redirect for SEO.

http:// vs http://www: Should I use subdomain or permanent redirect

As far as I can work out, http://www.example.com is technically a subdomain of http://example.com.
Is it better to have www.example.com as a separate subdomain (pointing at the same content), or is it better to do a perminent redirect of all traffic from http://example.com to www.example.com (or visa versa)?
Excuse my ignorance, but the reason I ask is that I'm worried that having two locations online (one with the www, one without), could cause problems with SEO, cookies, analytics etc.
Thanks!
G
Yes, if it is the same content, then give it a single URI; and redirect example.com -> www.example.com not the other way around (www. is the convention and is where systems will most likely look first). If you host on both urls, then Spiders and other bots may be smart enough to realize that it is the same, but why rely on it when a simple redirect ensures they know?
This also means a slightly simple web server setup (only hosting a single domain) and will be easier down the road if you do things like enable ssl or load balancing.
The only (arguable) downside to redirects is that it will mean an additional http request if the user gets it wrong.

HTTP redirects showing ip address

I have a domain name on 1&1 and a VPS on Linode. I noticed that my site was enclosed in a frameset which I didn't create. I checked nginx and jetty in the VPS but none of them created the frameset. Then I checked the domain control panel in 1&1 and saw that the redirection could be a frame redirect or an http redirect. I changed to http redirect and the frameset was gone, everything was fine except for the fact that in the url bar of the browser it changed to the ip address of the server instead of my domain url. How can I avoid the frameset and still have the proper url displayed instead of an IP?
I asked it in ServerFault and the answer was to point the domain's A record at my VPS.

Resources