ASP.net MVC Routing with Arbitrary # of Leading Segments? - asp.net-mvc

So, this is both a technical and a SEO question.
Let's say you are developing an e-commerce site and the client requests that you maintain the category path in the structure of the URL. Example:
/electronics/video-games/ps3/nba2k13-p123774
How do you set up a route that will work for this and send things to the product controller regardless of the number of segments before the last segment? Example:
{arbitrary_cat_routes}/{name}-p{id}
Secondly, I understand wanting to get keywords in the URL, but is there a substantial benefit to this? I've heard that content closer to the root of the site receives some SEO preference. Doesn't buring it 3 directories deep wipe out the SEO benefit of having the keywords there?

The ASP.NET MVC routing does not support a catchall parameter anywhere in the URL just on the end. You would need to create a custom Route class that implements this functionality. This blog post summarizes how you would that. To answer your second question, I would avoid having category metadata in the URL, but I'm not super familiar with SEO.

Related

Custom URL Routing in Blazor

Not having done much with MVC (lots and lots of ASP.NET Applications though) and Blazor, I'm fighting to get my head around how to accomplish what I want in Blazor.
In ASP.NET I would use the NuGet package for FriendlyUrls to accomplish this task.
I want to be able to define a list of URLs or generate them on the fly and have them route to a page I already created.
For example, I might have www.sitename.com/MyArticleName and I want it route to www.sitename.com/articles/1/ behind the scene. So the URL would look like /MyArticleName but in reality it's rendering the /articles page with a fixed ID.
My table in the DB is basically (a bit more to it though) is URL, Rewrite URL.
I can define the routes up front in some cases but when it comes to things like the articles , I would rather not define all the URLs up front as the user can add/rename/delete articles at any time.
Hopefully that makes sense. I know I can do a page like #page "/articles/{articlename}", but I don't want the user to see the /articles part of the URL.

Prefix or part of URL

I will develop tourist site about region. This site will consist of parts about cities in this region. Parts have same design and features. Home page of site will has information from all parts about all cities.
How do I design path structure of site? I saw that some sites for same purpose use prefixes like:
city.region.com
But another sites just add part to URL:
region.com/city
What is the best solution? (from SEO and Rails development points of view)
When you add a prefix to the site name, that is considered a subdomain. Subdomains are considered separate website so If SEO is a goal of yours, you will have a higher chance of showing up multiple times for a search.
On the other hand, I consider it a lot easier to add to the URL. This is the approach I would take, avoiding any premature optimization.
Source : http://www.ameravant.com/article/3398-subdomains-and-seo-pros-and-cons-of-subdomains-vs-subdirectories

how can I localize mvc routes?

I am currently working with localizing my MVC4 web application and have run in to an issue. My site is in four languages, English, French, Russian and Polish. I set up the sites culture based upon what the user selects. This is not tracked in the url.
I want my urls to be SEO friendly. So I need them to be localized. The tricky part though is that fact I routes set up for my controllers in English. For example
/product/product-name is mapped to the product controller and the get action
/customer/details is mapped to the customer controller and the details action
How can I localize the routes to different languages/cultures? So when I create an action link it maps to correct controller/action, generating the localized url?
I found this solution and it is very elegant but the issue I have is that it does not work as well for dynamic url's, as there is a need for explicit mapping.
Actually I don't know the right answer for that question and it's really very interesting how it possible to do that with standard MVC routing.
But if you do not find proper way to implement that with standard options you could implementing that by hands with the helps of front controler.
You create the class which will be main point of availability inside your app. And inside that method you could implement redirecting logic which will redirect you to the proper controller/action.

ASP.NET MVC - Shortening urls

I am developing an international web site - multiple countries, multiple languages. I am trying to create SEO friendly URLs.
For example the catalog consists of cartesian product Regions x Categories. A typical catalog url has 7 levels of hierarchy:
www.site.com/en/Catalog/Browse/10/28/London/Category1
The route format is as follows:
"/{culture}/{controller}/{action}/{regionId}/{branchId}/{region}/{branch}"
I have read somewhere that search engines give less relevance to pages deep in the site hierarchy (determined by number of slashes in path). Is this true? Does anybody have info on how much relevance do deep sites lose?
I have thought about simplifying the URLs (making them less deep) by using '-' and '+' as delimiters, so now I have routes like for example:
"/{culture}/friendlyActionPlusControllerName/{regionId}-{branchId}/{region}+{branch}"
ending up with urls still 4 levels deep in "folder" hierarchy.
www.site.com/en/services/10-28/London+Category1
Is using + and - in URLs considered a viable approach? Does this kind of shortening help in SEO? Does anyone see any options for me how to further simplify the URLs?
Additional note: Catalog is going to be the main source of search engine traffic. There are going to be a few content pages as well (with urls like www.site.com/en/Service1) but these two are going to be the only search traffic generators, so I would like to have them optimized as much as possible.
From my experience, I suggest you use the - (hyphenated). If you can keep the number of hyphens to 2 or 3, that is probably the safe route to take. Although I have seen people who go beyond that and it works just as well.
Basically I think if you do it in a way that is purely descriptive of the page content without going overboard, you're okay. However it should also be noted that the more keywords in your url's then the more diverse your page is going to be for Search Engines.
Also remember that keywords in the title, h1, meta data should all match up so the more you have the more difficult this is to manage.
I realise that this does not answer your question 100% and leads to more questions!
There is an open source project that implements shortening URL in aspnet mvc on codeplex, you can get it here:
http://miniurl.codeplex.com/

Geeky urls to Search Engine Friendly urls in IIS without sacrificing incoming links

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.

Resources