mod_rewrite

Anybody could notice that there are at least two urls that direct to this page. Originally, I registered for and . Both works well thanks to Drupal site configuration method. Drupal use name based resolution. All I have to do is to edit the setting.php to point to the same database for both of the name. Users can access my site using any of these urls and drupal simply direct it to the same place (because all information is stored in the database).

The problem is that the module from drupal that access these API does not allow me to authenticate with the API using different certificate for different host name. This is definitely not the bug of drupal because what I did in the first place is a workaround, not a recommended way. I personally says that the two urls use the same database which is originally intended to be used for single url.

The problem started when I was trying to use off-site module, e.g., Google Analytic, reCAPTCHA or mollom. These APIs require some security measurement. The APIs are available for the registered site only and they all adopt the name based identification. The method they adopt is that the RSA key is provided to the site owner and the site must supply the key when communicating with the APIs providers. Different keys are issued for different host name. In short, each call of this APIs must come from the correct URL.

RewriteCond %{HTTP_HOST} ^our\.obor\.us$ [NC]
RewriteRule ^(.*)$ http://www.nattee.net/$1 [L,R=301]

The first line simply matches the content of HTTP_POST variable with our.obor.us (using regular expression) as a first token. Then [NC] flag indicates that case is irrelevant. The second line simply match everything after the host name and prefixes it with http://www.nattee.net/. The $1 is back reference to the first line and [L,R=301] means that this line is the last rule to apply and apache should send the redirect command to the client.

That’s all.

Now, it came across my mind that mod_rewrite would solve the problem. mod_rewrite is an apache module rewrite the name of the url, perfectly what I want. After reading some document, all I need to do is to put these two lines on the .htaccess

Originally, I wish to solve the problem by redirecting anything from http://our.obor.us/ to http://www.nattee.net/. The problem is that GoDaddy won’t allow so, (they actually have this option but when I turned it on, nothing happens). For about a year after I adopt reCAPTCHA, nobody can post comment on http://our.obor.us/.

Syndicate

Subscribe to Syndicate
© 2014 Nattee Niparnan. Drupal theme by Kiwi Themes.