Redirect all urls except root from one domain to another domain along with path - redirect

I am trying to redirect a domain URL along with the path it is accessed with to another domain to same path. For example I have a URL jatinkamboj.in/cv which redirects to jatinkamboj.me/cv or jatinkamboj.in/stackoverflow which redirects to jatinkamboj.me/stackoverflow (dynamically for any URL slug) using the following cloudfare setting.
But the issue is I do have a separate site hosted for root domain i.e. jatinkamboj.in but after setting the above page rule in Cloudfare it too gets redirected to https://jatinkamboj.me/?utm_source=domain_jatinkamboj_in_ as per the cloudfare configuration. But if I go to jatinkamboj.in/index.html then it shows the root hosted website.
Is there any way around to have .in domain let host its root website

Related

How to shorten a Github.io webpage name [duplicate]

I have a gh-pages branch in one of my http://github.com repos. The GitHub project pages works fine if I go to http://myuser.github.com/myrepo
I want to setup a custom domain (myexample.com) that will serve up this project pages. I want both myexample.com and www.myexample.com to serve up these project pages.
GitHub pages help says to make an A record and a CNAME record in your DNS. The A record makes sense, but I do not know what CNAME record to make in my DNS.
The gh-pages docs say to make a CNAME record for 'charlie.github.com' which is a user page repository. I do not have a user page repository - I only have a project repository and a gh-pages branch that I want to use for myexample.com and www.myexample.com.
Do I need to make a user page repository just so I can use my project page for www.myexample.com and myexample.com?
I would just try it, but I want to make sure this will work as I already have www.myexample.com live and don't want to make a mistake.
I emailed GitHub support and their response was
You can't have both point to the same gh-pages as far as I know.
I find it hard to believe they would only support A records for project pages.
Has anyone successfully done this before?
1/23/19 UPDATE:
Things have changed quite a bit (for the better) since my last answer. This updated answer will show you how to configure:
Root apex (example.com)
Sub-domain (www.example.com)
HTTPS (optional but strongly encouraged)
In the end, all requests to example.com will be re-directed to https://www.example.com (or http:// if you choose NOT to use HTTPS). I always use www as my final landing. Why(1,2), is for another discussion.
This answer is long but it is not complicated. I was verbose for clarity as the GitHub docs on this topic are not clear or linear.
Step 1: Enable GitHub pages in GitHub settings
From your repo, click on the tab
Scroll down to the GitHub Pages section. You have two options:
Choosing master branch will treat /README.md as your web index.html. Choosing master branch /docs folder will treat /docs/README.md as your web index.html.
Choose a theme.
Wait a minute while GitHub publishes your site. Verify it works by clicking on the link next to Your site is ready to be published at
Step 2: Specify custom domain in GitHub settings
Enter your custom domain name here and hit save:
This is a subtle, but important step.
If the custom domain you added to your GitHub Pages site is example.com, then www.example.com will redirect to example.com
If the custom domain you added to your GitHub Pages site is www.example.com, then example.com will redirect to www.example.com.
As mentioned before, I recommend always landing at www so I entered www.example.com as pictured above.
Step 3: Create DNS entries
In your DNS provider's web console, create four A records and one CNAME.
A Records for # (aka root apex):
Some DNS providers will have you specify #, others (like AWS Route 53) you will leave the sub-domain blank to indicate #. In either case, these are the A records to create:
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
Check the Github docs to confirm these are the most up-to-date IPs.
Create a CNAME record to point www.example.com to YOUR-GITHUB-USERNAME.github.io.
This is the most confusing part.
Note the YOUR-GITHUB-USERNAME NOT the GitHub repo name! The value of YOUR-GITHUB-USERNAME is determined by this chart.
For a User pages site (most likely what you are), CNAME entry will be username.github.io, ex:
For a Organization pages site, CNAME entry will be orgname.github.io, ex:
Step 5: Confirm DNS entries
Confirm your A records by running dig +noall +answer example.com. It should return the four 185.x.x.x IP addresses you entered.
Confirm your CNAME record by running dig www.example.com +nostats +nocomments +nocmd. It should return a CNAME YOUR-GITHUB-USERNAME.github.io
It may take an hour or so for these DNS entries to resolve/propagate. Once they do, open up your browser to http://example.com and it should re-direct to http://www.example.com
Step 6: SSL (HTTPS) Configuration. Optional, but highly recommended
After you have the custom domain working, go back to the repo settings. If you already have the settings page open, hard refresh the page.
If there is a message under the Enforce HTTPS checkbox, stating that it is still processing you will need to wait. You may also need to hit the save button in the Custom domain section to kick off the Enforce HTTPS processing.
Once processing is completed, it should look like this:
Just click on the Enforce HTTPS checkbox, and point your browser to https://example.com. It should re-direct and open https://www.example.com
THATS IT!
GitHub will automatically keep your HTTPS cert up-to-date AND should handle the apex to www redirect over HTTPS.
Overview
The documentation is a little confusing when it comes to project pages, as opposed to user pages. It feels like you should have to do more, but actually the process is very easy.
It involves:
Setting up 2 static A records for the naked (no www) domain.
Creating one CNAME record for www which will point to a GitHub URL. This will handle www redirection for you.
Creating a file called CNAME (capitalised) in your project root on the gh-pages branch. This will tell Github what URL to respond to.
Wait for everything to propagate.
What you will get
Your content will be served from a URL of the form http://nicholasjohnson.com.
Visiting http://www.nicholasjohnson.com will return a 301 redirect to the naked domain.
The path will be respected by the redirect, so traffic to http://www.nicholasjohnson.com/angular will be redirected to http://nicholasjohnson.com/angular.
You can have one project page per repository, so if your repos are open you can have as many as you like.
Here's the process:
1. Create A records
For the A records, point # to the following ip addresses:
#: 185.199.108.153
#: 185.199.109.153
#: 185.199.110.153
#: 185.199.111.153
These are the static Github IP addresses from which your content will be served.
2. Create a CNAME Record
For the CNAME record, point www to yourusername.github.io. Note the trailing full stop. Note also, this is the username, not the project name. You don't need to specify the project name yet. Github will use the CNAME file to determine which project to serve content from.
e.g.
www: forwardadvance.github.io.
The purpose of the CNAME is to redirect all www subdomain traffic to a GitHub page which will 301 redirect to the naked domain.
Here's a screenshot of the configuration I use for my own site http://nicholasjohnson.com:
3. Create a CNAME file
Add a file called CNAME to your project root in the gh-pages branch. This should contain the domain you want to serve. Make sure you commit and push.
e.g.
nicholasjohnson.com
This file tells GitHub to use this repo to handle traffic to this domain.
4. Wait
Now wait 5 minutes, your project page should now be live.
Short answer
These detailed explanations are great, but the OP's (and my) confusion could be resolved with one sentence: "Direct DNS to your GitHub username or organization, ignoring the specific project, and add the appropriate CNAME files in your project repositories: GitHub will send the right DNS to the right project based on files in the repository."
If you are wondering how to get your domain to appear as www.mydomain.com instead of redirecting the www request to
mydomain.com, try this:
CNAME file on gh-pages branch will have one line:
www.mydomain.com (instead of mydomain.com)
No matter your preference on redirection (in other words, no matter what is in your CNAME file on the gs-pages branch), with your DNS provider, you should set it up like this:
A # 192.30.252.154
A # 192.30.252.153
CNAME www username.github.io
As of Aug 29, 2013, Github's documentation claim that:
Warning: Project pages subpaths like http://username.github.io/projectname will not be redirected to a project's custom domain.
I just discovered, after a bit of frustration, that if you're using PairNIC, all you have to do is enable the "Web Forwarding" setting under "Custom DNS" and supply the username.github.io/project address and it will automatically set up both the apex and subdomain records for you. It appears to do exactly what's suggested in the accepted answer. However, it won't let you do the exact same thing by manually adding records. Very strange. Anyway, it took me a while to figure that out, so I thought I'd share to save everyone else the trouble.
Things are lot easier nowadays!
Update your Apex domain (#) record to point
192.30.252.154
192.30.252.153
Edit your Custome domain field in your github repo settings.
www and other subdomains can be updated as CNAME to apex domain.
The selected answer is the good one, but is long, so you might not read the key point:
I got an error with the SSL when accesign www.example.com but it worked fine if I go to example.com
If it happens the same to you, probably your error is that in the DNS configuration you have set:
CNAME www.example.com --> example.com (WRONG)
But, what you have to do is:
CNAME www.example.com --> username.github.io (GOOD)
or
CNAME www.example.com --> organization.github.io (GOOD)
That was my error
I'd like to share my steps which is a bit different to what offered by rynop and superluminary.
for A Record is exactly the same but
instead of creating CNAME for www I would prefer to redirect it to my blank domain (non-www)
This configuration is referring to guidance of preferred domain. The domain setting of www to non www or vise versa can be different on each of the domain providers. Since my domain is under GoDaddy, so under the Domain Setting I set it using the Subdomain Forwarding (301).
As the result of pointing the domain to Github repository, it will then give all the URLs for both of master and gh-pages.
As addition to the CNAME file above, you may need to completely bypass Jekyll processing on GitHub Pages by creating a file named .nojekyll in the root of your pages repo.

Keycloak client URL configuration of redirectURLs

I am having trouble trying to figure out what the values should be for 'Valid Redirect URIs', 'Base URL', 'Backchannel Logout URL'.
I am using Keycloak 15.02 along with 10 Spring Boot applications, and 2 Realms. The suite of applications and Keycloak are deployed to our customer sites, and may have more than 2 realms in some cases.
In our dev environment we have two hosts (api.dev, and web.dev) that are running Keycloak, and client apps. Everything is running Docker containers.
The client config for `Valid Redirect URIs', and 'Backchannel Logout URL' currently include the host name web.dev. I'd like to be able to remove that host name to make the Realm configs portable between environments. Having to configure each client in each realm makes for a lot of repetitive and mistake-prone work.
But when I remove the hostname, I get the error: Invalid parameter: redirect_uri.
The redirect URL shown by Keyloak in the request parameters looks the same for both configurations so I dont really understand why its telling me that its invalid.
This works:
That configuration produces the redirect_uri value seen in the following request:
http://api.dev.etisoftware.local:8080
/auth/realms/OSS/protocol/openid-connect/auth
?response_type=code
&client_id=launchpad
&scope=openid%20profile%20email%20roles
&state=E-8VBZUc1CbsIUi5HdPG68pNK1IVNB8bzDT3Aengx9Q%3D
&redirect_uri=http://web.dev.etisoftware.local/launchpad/login/oauth2/code/OSS
&nonce=3OUMxVmrglSC0KK-WGWDjG4yB9TOuvqBO5TMnDk4R-A
But this does not:
That configuration produces the redirect_uri value seen in the following request:
http://api.dev.etisoftware.local:8080
/auth/realms/OSS/protocol/openid-connect/auth
?response_type=code
&client_id=launchpad
&scope=openid%20profile%20email%20roles
&state=cGh1zZ3et0ssogIsNclL2sHcrfDxNePaHf5UXxw0aR8%3D
&redirect_uri=http://web.dev.etisoftware.local/launchpad/login/oauth2/code/OSS
&nonce=Qm846RYZZnU3fG4Cj75e8lBejupf24VbV1WjDVW1NJA
As you can see the values for redirect_uri in the request parameters are same for both requests and client configurations so its unclear (to me) what Keycloak is trying to tell me.
I also happen to have Keycloak and the client apps running in a K3s cluster. For some reason on that environment I dont have to have the hostname in the Valid Redirect URIs and it works perfectly fine. Is it just a fluke?
Redirect URIs tooltip:
"Valid URI pattern a browser can redirect to after a successful login or logout. Simple wildcards are allowed such as 'http://example.com/’. Relative path can be specified too such as /my/relative/path/. Relative paths are relative to the client root URL, or if none is specified the auth server root URL is used. For SAML, you must set valid URI patterns if you are relying on the consumer service URL embedded with the login request"
So if you want to use relative paths in the redirect URIs, then configure properly Root URL, not Base URL.
I got this answered on Keycloak's site but Jangaraj.
https://keycloak.discourse.group/t/trouble-with-configuring-client-valid-redirect-uris/13251

Google admin console use with github hosted website

I have purchased a domain through the google admin site (G suite), and I am trying to use it in conjunction with a page hosted on github. In google admin I have added a domain alias that is the url pointing to the github page I have hosted. And through github under the 'Github Pages' section of settings I have changed the custom domain to point to the purchased domain I have. But for some reason the webpage I have in my github repository is not displaying on the domain I have purchased. Instead when I navigate to the domain I have purchased, nothing displays, and when I go to the github url of my hosted page it reroutes me to my purchased url.
Am I doing something wrong?
Here's how I set up http://jsonp.therobinkim.com/ to point to https://therobinkim.github.io/lets-learn-jsonp.
On GitHub, from https://github.com/therobnkim/lets-learn-jsonp settings, I put jsonp.therobinkim.com under my GitHub Pages Custom domain settings.
On Google Domains, from my custom domain's DNS settings, I added a new Custom resource record:
jsonp, my custom subdomain (changed from default #)
CNAME, bc we're pointing to another website by name instead of IP address (changed from default A)
1m (changed from default 1h, but not necessary)
therobinkim.github.io (changed from placeholder IPv4 address)
It started working for me within 5 minutes.
I hope this helps!
You need to create a cname file on your github repository. It is as simple as creating a file called CNAME, then putting your domain on it, i.e. yourdomain.com

Google search showing up the Amazon S3 website link

This is how I set up redirection to the Amazon S3 site:
(Basically followed instructions from here)
Set up a bucket called www.mysite.com and configured it for static website hosting
In my Godaddy account, configured:
Added a CNAME entry for 'www' to point to the publicly accessible S3 site (like mysite.in.s3-website.amazonaws.com)
Added a forwarding rule (302 redirect) to make both mysite.com and www.mysite.com work - whenever someone types in mysite.com, it redirects (browser url bar changes) to www.mysite.com.
Coming to my actual problem - when I do a Google search, the pages are listed under the S3 site ( mysite.in.s3-website.amazonaws.com) - which I'd like to think of as an implementation detail. Is there something else I should do to get google recognize and show links under mysite.com ?

Showing a GitHub project page only under custom subdomain, never via folder path

I have an organization GitHub Pages repository set up, and it's served through a custom domain name (let's say, http://example.com/).
I also have a couple of projects pages which I want to be accessible via a subdomain only (let's say, http://project.example.com/), but it turns out that they will also be accessible at a different URL (that is, http://example.com/projectname/).
Is there any way to avoid this? Both the organization pages and the project pages have CNAME entries set up, and the DNS records seem to be correctly configured.
http://project.example.com/ will also be accessible at http://example.com/projectname/
> Is there any way to avoid this?
I was able to avoid this via a project pages setup for each subdomain as well as the domain. It didn't work with CNAME records so I had to use A records in the server side configuration. Every record would point to the Github IPs 192.30.252.153 and 192.30.252.154, using the subdomain as host or # for the domain.com part.
For future users looking into how to map a Github page to a domain / subdomain:
Create new Github repo and add a gh-pages branch.
Add your index.html and a CNAME file with only one line sub.domain.tld.
See this gist for more details.
The only solution that I am aware of is hiding http://domain.tld/projectname/ content with a robots.txt file on the web server that serves that domain.
http://en.wikipedia.org/wiki/Robots_exclusion_standard