Wednesday, January 30, 2013

Rewrite no-www to www with nginx

I had to redirect all users who entered the address without "www" to the address with "www".
For example:

  •  "domain.com" -> "www.domain.com"
  •  "domain.com/users" -> "www.domain.com/users"


I'm using Engine Yard and the nginx configuration files are there :
/data/nginx/servers

Here you can see DOMAIN.conf. Do not modify this file ! I did it and later I found out that my modification was removed. This happened when you "apply" or "upgrade" your environment, this file is re-created.
The file you should modify is /data/nginx/servers/DOMAIN/custom.conf
(If you look at the bottom of DOMAIN.conf, you can see that custom.conf is included)
Here is the code:

if ($host = domain.com) {
    rewrite ^(.*) http://www.domain.com$1;
}


Then I was doing "touch tmp/restart.txt" and the redirection was not working...
Because in fact you should do this:
sudo /etc/init.d/nginx reload

Of course if you're using "https", you should modify "custom.ssl.conf" !

Saturday, January 5, 2013

Android source code

For a project, I'm looking at the source code of Android.
And I could find this comment in RadioInfo.java:
// This is hardcoded IP addr. This is for testing 
// We would need to get rid of this before release.


Looks like they forgot to remove it.
(packages/apps/Settings/src/com/android/settings/RadioInfo.java)