Is there a solution to the following that I am missing in SharePoint/CAML. Note that I'll give a specific example of using a URL on a Redirect Page (publishing feature content type), but the issue is broader in scope than provisioning a Redirect Page. It is really a question anywhere a "URL" field/property can be set (web parts, pages, etc).
Like most SharePoint developers, I have a set of environments: "DEV", "QA", "STAGING", and "PROD". I have a few "locale" specific sites in each environment:
www.mysite.com
us.mysite.com
uk.mysite.com
etc...
Sites in each environment, other than PROD, have an environment prefix associated with them, for example:
us.dev.mysite.com
us.qa.mysite.com
us.staging.mysite.com
Probably a pretty common setup...
I have a need to redirect users to a page that only exists on the "www" site from each of the locale specific sites. I need the redirect to redirect users to appropriate "www" site for the environment they are currently in. For example, if I am in dev in the uk locale, and I visit the redirect page, I should be redirected to the www dev site.
I was hoping to use a "Redirect Page" from SharePoint to accomplish this. I was going to setup a feature (with module elements) to provision an instance of the "Redirect Page" content type. This allows me to specify a url to redirect users to. If I am provisioning the page through CAML, however, I need a way to ensure the redirect is appropriate for the environment being specified. I cannot trust myself, or other devs, to remember to change the URL each time we build and deploy the wsp to each environment.
Is there anyway in SharePoint/CAML to do some sort of token replacement based on some switch when specifying field/property values?
I'm not sure I understand you requirements entirely, but for the variance of environments (Dev, QA, Staging, Prod), I would use Chris O'Brien's 'Config Store' feature:
http://www.sharepointnutsandbolts.com/2008/05/introducing-sharepoint-config-store-for.html
This will create a simple list where you can store infomation specific to the current environement.
This combined with Gary Lapointe's stsadm extentions:
http://stsadm.blogspot.com/2007/08/stsadm-commands_09.html
You can use this to push out the correct values per environment to your 'Config Store' and in your code, query the 'config store list' for the environment value.
For sites that represent different countries, you can vary them on the regional settings property for that site/site collection/web. This adds another dimension to check in your code.
In your case, you may have entry in the config store called 'MyPrefixUrl' and call its value + relative path to redirect the user to the correct place.
Hope this doesn't confuse you.
Related
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 have a Magento website that is running in production environment for a year now.
Now we want to create a Wholesale and retail store in this same installation. We are did that in a test environment and everything works fine.
So, before multistore created, we had our URL example.com.
Now, we are using different websites, setting "Add Store Code to Urls" to YES, so we have:
Retail: example.com/default
Wholesale: example.com/wholesale
However, my URL's will be "broken" when someone search for it on Google. Is there a way to set up when someone try to access a URL without store code, to add the "default" code (for retail store)?
You may solve this using .htaccess / virtual hosts combined with magento run code. There are many resources with in depth articles (like the first google result I got).
I would like to create the following scenario in my web project, but as I am not pro web developer I don't know how to handle this.
Let's assume that I have project with main domain:
http://foobar.com and on this I have a links to the following subdomains:
http://xx.foobar.com
http://yy.foobar.com
I would like to that every site hosted on subdomains used the same code with only one different parameter sent to the subdomain from main page. This parameter will be a JavaScript variable. I am using Azure Web Sites from my project. The main question here is how to manage the code (now I am using Continuos Integration with GitHub) through these subdomains (the source code for every subdomain would be the same, except this one variable). Where should I start to search / read?
Are you passing any value for the parameter? Or is it just a static parameter? If it's static, you could possibly use JavaScript code to read the subdomain name in the URL.
Not sure what language you're using on the server, but you should also able to read the subdomain via server-side code.
But if its value is dynamic, the main page with the links can generate a QueryString parameter to pass along in the URL. Your implantation will vary depending on what language you've selected.
UPDATED, with additional info:
When you say "share the project source code between subdomains", do you mean that you want to deploy the same web app to multiple endpoints?
If so, you can create a separate Web App in Azure (formerly known as Azure Web Site) for each corresponding subdomain, and set up your source control to deploy to both of them whenever you check in your code.
References:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/
https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
Since you have no server-side code, I'm using you have only HTML/JavaScript/CSS files. So, you can write JavaScript code to read the parameter from the URL.
References:
http://www.w3schools.com/jsref/prop_loc_href.asp
http://www.w3schools.com/jsref/prop_loc_pathname.asp
http://www.cssmojo.com/the_location_object/
As I mentioned earler, you would set up the links on the main index page to pass in QueryString parameters:
e.g.
Link 1: http://sub1.mywebsite.com/?param1
Link 2: http://sub2.mywebsite.com/?param2
Hope that helps!
First, make sure you point your domain to your azure website using wildcard (references)
Second, in your html head, find the subdomain using javascript and assign in to the variable you want to use
var full_url = window.location.host; // e.g. subdomain.host.com
var parts = full.split('.'); // split it
var subdomain = parts[0];
now you can use the subdomain variable to change your website based on subdomain value (e.g. change the content)
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.
A friend of mine set up a website with a website builder. I offered to help and ended up redesigning the site. What I wrote is obviously incompatible with the site builder's templates he used, but he would rather stick with the site builder which allows him to make the changes he needs to make.
What I'm currently thinking is to have both sites set up simultaneously and let him choose which one is visited by the user. That way we can use the new site and then when he makes a change, switch back to the old site until I have a chance to change the new version. This would be confusing for any regular users of the site who happened to visit it in the time that the old site was changed, but the site is very small with very few visitors, and any changes made would be easy to duplicate.
I don't, however, know how to do this. My first thought was to have two public_html directories with a script that would rename them as needed, but I don't know how I would go about changing the name of a folder that a script is running from. I also don't think I would be able to move the old site over to a host I control; the site builder doesn't give the ftp details and it takes care of all the dirty work for its users. At most, I think I could transfer the domain name to a different registrar, set up the nameservers with the host of the new site, and go from there, but then the old site wouldn't be editable from the site builder...
My second thought would be to do something like this in php:
if(...){
echo file_get_contents(oldsite . $_SERVER['REQUEST_URI']);
}
else{
...
}
If anyone's made it this far, here are the key points of what I want to achieve:
Old site is able to be changed with the site builder (vistaprint)
Script to choose which website the user visits
Urls never change
Assume the only control we have over the old site is a simple WYSIWYG editor from the site builder and the ability to change the domain as well as release the domain (for $20, the crooks). Nothing to do with nameservers, ftp, file managers, etc.
Current plan of action: Transfer the domain (lets assume it's http://example.com) to a register and webhost I control. Set up an add-on domain (http://old.example.com) and register the web builder with the addon domain. I'll then have each page set up the way I showed in the second plan:
if(...){
echo file_get_contents('http://old.example.com' . $_SERVER['REQUEST_URI']);
}
else{
...
}
I'm a bit reluctant to do this for a number of reasons, so I was hoping someone could enlighten me on a better method.
You're overthinking this. Just redirect (HTTP status 3xx) to your old site when necessary.