When I view sites in other languages, their URLs either change to http://ru.wikipedia.org for example or http://somesite.com/ru/.
I think in first example they use third-level domain, in the second they use root subdirectory (folder).
So I am interested: is there any difference? how do these structures work and why do they exist?
I remember three reasons why I went away from the third-level domain solution:
You have to explicitly take care about cookies. They have to be set for the top-level domain to be shared between all domains.
Also you have to ensure that you are referencing all assets (images, css, javascript) absolutely to leverage browser caching.
It's just guessing (I'm not an expert in this area) but you are also influencing search engine relevancy as the third-level domains won't count in the second level domain that much.
ru.wikipedia.org - The 'ru' here is a subdomain. This acts as a redirect to another location. In most cases this is a subdirectory on the site, but it is also used to redirect to any other URL.
somesite.com/ru/ - The 'ru' here is usually a subdirectory, but it can also be a RESTful web service. Twitter is a good example of a RESTful web service (a subdirectory doesn't exist for each user, but the content is dynamically created at runtime).
Subdomains such as ru.wikipedia.org are usually used for subsites - such as the Russian version of Wikipedia.
Related
I have an umbraco installation.
I published a content named "Account" and umbraco gave it this url /account.
Fair.
Then I published a content named "Register" under content Account (I allowed Account Doc Type to have Register Doc Type as child).
I would expect the url of the new content to be /account/register, but umbrace gave it /register.
Why is this happening? What's the point of allowing child content types, and building a content tree, if the urls are all from root? As a newbie to umbraco, I consider it a logic flaw. For a CMS that claims to be friendly, that's not friendly at all. I'm a developer but I can't waste half of my day looking for umbraco answers and tutorials online. A friendly CMS should be self explicatory while being used, and should take care of all common assumptions a newbie may have.
How can I make the Account->Register content node to appear in /account/register url?
I think what you're seeing is a side-effect of a feature in Umbraco that is supposed to support the pattern most develops use when creating an Umbraco website.
The best practice when building Umbraco websites is to create a "Website/Root/Site" document type and place this in the root of your hierarchical content structure. Beneath this document type you place each of your pages as direct children. This allows you to set hostnames and culture on your site as well as it allows you to keep your entire site in one "bundle", and it also allows you to do multiple subsites within the same Umbraco website. It is pretty common practice to structure your website this way.
However - as you expect - this would give your URLs such as domain.com/website/account/register due to Website now being an actual content node in Umbraco. As this is really not something anyone would want - Umbraco has a built-in feature allowing the top level node to be hidden from the URL path. This results in your URLs being domain.com/account/register in this case.
If you however consider your site - this feature results in your register page getting the URL: /register since the /account part is a top level node that will be ignored when generating URLs.
This behavior is triggered by the setting umbracoHideTopLevelNodeFromPath which can be found in web.config of your site (true by default).
I would however recommend that you do not change this setting and instead add in the root node for your site as it will make things easier for you to manage in the future - it is also the best practice way to structure a site.
This should result in URLs being generated the way you are expecting them to be. Child nodes will have URLs that reflect their name and location in the content tree.
www.site.com/site/
instead of
www.site.com/site/index.php
www.site.com/articleName/
instead of
www.site.com/articleName.php
Its been around for so long, but I can't seem to find an article about it anywhere!
I know you can simply do it with directories and index.php files, but I'm sure most sites don't do it that way...
How do these guys do it? And apart from the URL looking nice and clean, what benefits does it gain?
For Apache/PHP mostly (.htaccess) rewrite rules are used. For IIS/ASP sites a URL rewrite module is usually used but there are many other techniques (like: a 'special 404-handler' that handles all non-existing URL's and figures out how to process the request).
Rewrite rules can be(come) very complex or very simple; a rewrite rule can be used for every method (or action) in the url or it can be as simple as passing every request to the same "index.php" (or equivalent) and letting the code handle the rest of figuring out what to do.
Why it's done? Mostly because of SEO reasons or "easy to remember url's" (who types in complete urls nowadays anyways?) or "user friendly url's". You might want to check out this article on wikipedia which also states
The technique adds a degree of separation between the files used to
generate a web page and the URL that is presented to the outside
world.
as a reason and summmarizes some drawbacks and benefits. Even more can be found here.
One way is to use Apache's mod_rewrite module.
I'm sure there are others...
You can use modrewrite on linux, isapi rewrite for iis 6 or 7 or url rewriting module for iis 7.5+.
Search for [friendly-url] here in SO to find dosens of answers.
It has now become a requirement that my existing project requires a different 'theme' for different clients. I have never had to do this on an ASP.NET MVC project and it doesn't seem like ASP.NET Theming and MVC go together very well.
I would say that 75% of the CSS will remain the same with the rest being changeable. It wouldn't have to be able to switch on-the-fly as they will be deployed as separate web sites (probably on different servers).
Just wondering if there was a preferred method for doing this sort of thing? I was thinking of just having a base CSS with separate 'client-specific' ones with overriding rules. The client css name could then be be set in the web.config and brought through to the master page for declaration.
Am I on the right track there?
We do this, with a similar approach as the one you described. Base CSS is always loaded, and CSS overrides are applied depending on the client.
The difference is that we don't use an appSetting, though you could. All of our clients are on the same server, so we manage it using a cookie. When a user signs in, we take the part after the # symbol in their email address and set a cookie corresponding to the client ID. Our CSS overrides are in a folder with the same name as the client ID.
We then have a child action that renders the additional CSS overrides in the head section, based on the cookie value.
I am working on site which is scattered in multiple subdomains. From the main site I have to create url which points to sudomains. How can I do this.
for example, my main site is www.mysite.com
I need to create a url pointing to blog.mysite.com/userId/Name which will point to HomeController and Index method witch userId and name.
Also, how should I handle the urls on local machine as well on the production machine.
Help will be appreciated
updating my question here.
What does
#Html.ActionLink("MyLink","Index","Profile","","www.test.com",null,null,null)
do.
It creates a link, but with port number in it. If there is anyway I can avoid it.
Regards
Parminder
As your sub domains will host their own applications with controller and actions I'd recommend to use the good old HTML hyperlink to create that link:
Your Blog
Why: Because you do not want to couple your disjoint applications and ASP.NET MVC does not have a clue (and should not have a clue) about the routes used in some other application. For constructing the link you can add an extension method to HtmlHelper to avoid typos and URL path encoding quirks.
Regarding port number-- you really need to set up a virtual directory in IIS to avoid it. And if you're goal is to have separate sites-- you're going to have to set up virtual directories for all the subsites as well. I am wondering if you really need to set up completely separate sites? How extensive will the subsites be? Will there be any connection between the "root" site and the "sub sites".
Out of curiosity--- how many subsites? If you can do it without revealing too much-- what is the end goal here?
If you are looking for string typed items you might want to use the razor #helper syntax.
You could create #helper.blogLink("Title", "Action", "Controller") that creates a link to the subdomain.
http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx
I have a website where my present "geeky" urls look like:
http://www.bestatdubaiholidays.co.uk/pages/Quote/Details.aspx?GUID=01a25b0c-e0ac-40ba-abd1-298f3abd9612
I want to change these to Search Engine Friendly ones - something like:
http://www.bestatdubaiholidays.co.uk/the-palm-atlantis.aspx
or
http://www.bestatdubaiholidays.co.uk/the-palm-atlantis
I have hundreds of incoming links (from ad campaigns and other sites) to my geeky urls that I want to retain.
So if someone types a geeky url, I want the address bar to show the equivalent search engine friendly url.
Can anyone help? Referring to other articles won't help. Believe me, I've read every one of them. Any example urls will be helpful.
Use something like this http://blog.eworldui.net/post/2008/04/ASPNET-MVC---Legacy-Url-Routing.aspx
You don't have to use MVC, the routing classes are standalone now
I suggest using a Front controller. This means that you use the rewrite engine of whatever httpd server you're using to redirect ALL requests to a single file (index.php or index.aspx or whathaveyou) and then you use code in that file to dispatch to the appropriate page. You can do a redirect from the geeky URLs to the friendly URLs, and if it's a friendly url then you load the appropriate page.
This would be way easier than writing huge rewrite rules for each type of page you might have. And this way all of the work is done in the same language your site is already running, so you don't have to learn and maintain a new file that is in its own language just for the redirection.