full of … these

Rewrite rule without losing the initial URI

Posted: November 9th, 2012 | Author: | Filed under: howto, idiots | Tags: , , | No Comments »

Today, I had to add a rewrite rule to keep the short word (keyword) after “domain.com/”.

So, you want to keep the keyword in the address bar, but load the long URI and not showing it.

Here is my solution:

RewriteRule ^/(keyword-or-short-name)/?$ /long/i-mean-long-very-long-with-lots-of-params.htm

Happy users!

 


RewriteRules for special characters

Posted: November 18th, 2009 | Author: | Filed under: fun, howto, idiots, linux | Tags: , , , | No Comments »

Let’s say you have to write RewriteRules for special characters (East Asian Languages in this example, but, it should work for any other).

Link that you want to work: http://domain.tls/리눅스
Destination http://domain.tld/linux

First you must convert/encode (I used http://people.w3.org/rishida/scripts/uniview/conversion.php)
리눅스 is converted to %EB%A6%AC%EB%88%85%EC%8A%A4
You can get this from your access.log file of your server if you access it.
Now, you have to escape the % to match the regexp. Replace % with \x:
\xEB\xA6\xAC\xEB\x88\x85\xEC\x8A\xA4

RewriteEngine On #add it in case it was not added above
ewriteCond %{HTTP_HOST} domain.tld
RewriteRule ^/\xEB\xA6\xAC\xEB\x88\x85\xEC\x8A\xA4$ http://http://domain.tld/linux

Save.
Restart or reload.
mod_rewrite should be loaded.
Test!
Debug: read /var/log/httpd/error.log and access.log (or corresponding error/access log file for the vhost you want the rule to be added.