I have a dyndns.org account which goes to my home computer. That all works fine, wordpress is installed.
I want to buy a domain (mysite.com) and have it mask to mysite.dyndns.org while passing back all of the additional URI goodness.
For example, if I go to mysite.com/page2 it should go to mysite.dyndns.org/page2
Any thoughts on ways to accomplish this?
The answer turned out to be to use a CNAME record. CNAMES essentially act like symlinks.
Yes, assuming you want to keep hash parameters in addition to query parameters, you could accomplish such a thing with a little piece of JavaScript like the following:
if (window.location.host == 'mysite.com') {
var current_url = window.location.href;
var new_url = current_url.replace('mysite.com', 'mysite.dyndns.org');
window.location.href = new_url;
}
If you don't need to preserve hash parameters, then you could implement similar redirect logic in the web server or in the server-side scripting language of your choice, by checking the HTTP "Host" header for the current host name, and issuing a 301 redirect as needed.
However, I really do not understand why you would want your system to be set up in this way. Typically custom domains are more trustworthy than domains hanging off of "dyndns.org". Why not just have your custom domain configured to point to the correct IP address(es)? Most web hosting solutions will automatically provide the appropriate DNS configuration.
Related
I set up a site using Azure Static Web Apps. I have two use cases I haven't been able to solve nicely for, and I think the same functionality might address both:
When a user is not authenticated, they're redirected to <my-site>/.auth/login/<my-auth-provider>. But, that means when they're brought back after logging in, they go to /index.html, which is not ideal. Most of the traffic to this site will be to specific leaf pages. I'd like to redirect to <my-site>/.auth/login/<my-auth-provider>?fromUrl=<the-requested-url> instead, if possible.
When a user requests a "pretty" url address e.g. <my-site>/pretty-url, I noticed that Azure SWA doesn't handle that the normal way, rewriting to <my-site>/pretty-url/index.html. I'd like it to at least try to rewrite to <my-site>/pretty-url/index.html.
It looks like neither of these are possible at the moment.
Here's a Github issue about redirecting after login, and one about enforcing trailing slashes.
I want to give my customer the ability to create their own todos list app/web.
So, I thought they could register to my application, for instance:
http://mytodos-app.com/signup and provide all preferences such as theme, title, name...
Now i could use the url/router ability to get some unique identifier from the url and use the same app, but fetch data for each customer.
i.e: http://mytodos-app.com/todos/:someuniqeid
1) is it sounds ok? or are there better strategies for this scenario?
2) if it's ok, If I want to give them the ability to configure their own domain (like in shopify you get some dynamic domain yourname.shopify.com).
So, what is the most popular/professional way to do it? I want it to be easy to the customer. any suggestions?
Other than the "cool factor", there is no benefit to using actual customized sub-domains.
You can synthesize the behavior by:
In DNS, set up a wildcard CNAME entry for *.DOMAIN.com to point to www.DOMAIN.com, be sure to buy a matching wildcard ssl/tls certificate.
Configure the web server to respond to all hostnames.
After user registration. SANITIZE the username(or whatever identifier) value.
Set an authorization cookie with the domain=DOMAIN.com option to force it not to
be a host cookie.
Redirect to username.DOMAIN.com. Same server different name.
Check the cookie in the route to serve the correct pages. Just like
you would with any login.
If there is no cookie, use the host information to populate the
username portion of the login page, or display public todos?
Make sure any Javascript scripts hosted on the site and all internal links are loaded by relative addressing.
The technique is much safer than actually creating real subdomains.
I had an argument with my friend about domain redirects. He is convinced that you can redirect one domain to another by using DNS records only, showing source URL in browser instead of target URL. I mean, without any access to webserver. I don't think this is the case but can't find a direct proof that it's impossible.
So I'm curious. Is there a way to do it?
Yes it's possible. It's sometimes called Stealth Forwarding and may or may not be offered by your domain name registrar.
I have set up a secondary domain on my BC hosting successfully and have already set it up to point to a homepage and the url stays the way I wish, for example www.[secondary domain].com
I now want to setup a web app to use my secondary domain rather than my default, does anyone know how I would achieve this?
Fore example at present it looks like this www.[default domain].com/[webapp name]/ I would really want it to read www.[secondary domain].com/[webapp name]
I am going to have to use redirects when promoting the page and just accept that the proper url is going to be www.[default domain].com/[webapp name]/
BC serves all content the same, no matter which domain it is accessed from.
Proper server-side 301 redirects are unavailable, since BC gives us no method to discriminate by domain. You can perform a client-side 'redirect' though, after comparing the hostname in Javascript (with something like document.location.host).
There is also Liquid Markup, which you can use to detect the domain and vary the served content accordingly.
You'll need to ensure all links to the app are fully qualified, including the preferred domain.
I'd also add canonical links (<link rel="canonical" href="...">) to each page of the app. This will indicate the preferred domain to search engines.
Note the inverse is also a problem; content on your primary domain will also be accessible through the secondary domain, causing rank dilution / duplicate content issues.
I've created a really simple databaseless php application that I want to offer as a hosted solution. I've enable wildcard subdomains so that users can sign up and create a subdomain (e.g. "user.myapp.com"). However, I would like to offer the ability for my users to use a custom domain as well if they prefer. I'm pretty sure this can be accomplished by asking the user to add an A Record to their custom domain pointing to my server's IP, but I'm not sure how to handle the domain on my end once they create an A Record pointing to my server's IP.
So, say a user signs up for my service under "user.myapp.com" and then they decide they want to use a custom domain "someuser.com" instead. My specific question is — once the user adds an A Record to their domain "someuser.com" pointing to my server's IP, how do I tell my server to point that domain to "user.myapp.com"? Or is there an easier way to do this?
You'd need to first setup your server to accept requests from someuser.com, which is entirely different than setting up a wildcard for your server alias (e.g. *.myapp.com). You can have a default vhost handle all the hostnames that no other vhost is setup to handle, but then you're still left with mapping someuser.com to user.myapp.com.
Depending on how you've setup your php application, the user's going to need to enter the custom domain they've registered that they had point to your app, then you'll need to know to do that mapping internally by checking the $_SERVER['HTTP_HOST'] server variable to see what host the request is for, and if it's for someuser.com, then map it to user.myapp.com.