Multi-lingual websites with ASP.NET MVC

The URL can take almost any other form you like. For more info, check ASP.NET MVC Framework (Part 2): URL Routing. Just for starting (since I am not sure if it is the optimum solution), you can add two new routes in your global.asax: routes.MapRoute( “ukRoute”, “{lang}/Products/{action}/{id}/{subcategory}”, new { lang = “uk”, controller = “Products”, … Read more

RewriteCond to match query string parameters in any order

You can achieve this with multiple steps, by detecting one parameter and then forwarding to the next step and then redirecting to the final destination RewriteEngine On RewriteCond %{QUERY_STRING} ^category=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} &category=([^&]+) [NC] RewriteRule ^index\.php$ $0/%1 RewriteCond %{QUERY_STRING} ^subcategory=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} &subcategory=([^&]+) [NC] RewriteRule ^index\.php/[^/]+$ $0/%1 RewriteCond %{QUERY_STRING} ^product=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} … Read more

How does url rewrite works?

There are two types of behaviour. One is rewrite, the other is redirect. Rewrite The server performs the substitution for itself, making a URL like http://example.org/my/beatuful/page be understood as http://example.org/index.php?page=my-beautiful-page With rewrite, the client does not see anything and redirection is internal only. No URL changes in the browser, just the server understands it differently. … Read more

jQuery on the fly URL shortener

Here is an example how to get a shortened URL with Bitly API and jQuery: function get_short_url(long_url, login, api_key, func) { $.getJSON( “http://api.bitly.com/v3/shorten?callback=?”, { “format”: “json”, “apiKey”: api_key, “login”: login, “longUrl”: long_url }, function(response) { func(response.data.url); } ); } The following code could be used to get a short URL: /* Sign up for Bitly … Read more

URL Rewrite keeps original host Location when reverse proxy 301 redirects

Could Application Request Routing be involved? Look at IIS -> Machine or Site -> Application Request Routing Cache -> Server Proxy Settings and uncheck the “Reverse rewrite host in response headers” checkbox. If you do this at the machine level, it’ll take effect for all sites. If you do it on a particular site, it’ll … Read more

Line endings messed up in Git – how to track changes from another branch after a huge line ending fix?

I finally managed to solve it. The answer is: git filter-branch –tree-filter ‘~/Scripts/fix-line-endings.sh’ — –all fix-line-endings.sh contains: #!/bin/sh find . -type f -a \( -name ‘*.tpl’ -o -name ‘*.php’ -o -name ‘*.js’ -o -name ‘*.css’ -o -name ‘*.sh’ -o -name ‘*.txt’ -iname ‘*.html’ \) | xargs fromdos After all line endings were fixed in all … Read more