Thursday, July 3, 2008

Apache Rewrite for underscore to hyphen

I have faced an url issue in my webapplication.

I was asked to rewrite the requests for the html pages which has "_" ,

Example :

http://mydomain.com/test/resource_with_underscore.html

(to)

http://mydomain.com/test/resource-with-underscore.html


the following rule will work fine for the above scenario,



RewriteRule ^/([^_]+)_([^_]+)_([^_]+)$ /$1-$2-$3 [L,R=301] #pages with 2 underscores
RewriteRule ^/([^_]+)_([^_]+)$ /$1-$2 [L,R=301] #pages with 1 underscore

Ref: http://underscorebleach.net/jotsheet/2005/04/perl-301-redirect-script

Thursday, February 14, 2008

Search for file with a specific name in a set of files (-name)

find . -name "rc.conf" -print

This command will search in the current directory and all sub directories for a file named rc.conf.

Note: The -print option will print out the path of any file that is found with that name. In general -print wil print out the path of any file that meets the find criteria.

Wednesday, January 23, 2008

How to find Linux Version ?

For Ubuntu,
Following file will contain the Linux version

/etc/issue

Tuesday, January 8, 2008

uninitialized constant Gem::GemRunner (NameError)

I think,this error is due to upgrading your gem version.

To reproduce this issue, follow the steps below

1> whereis gem

Ex : /usr/bin/ruby/gem ...and so on..

2> delete all the listed files & directories (only gem related files..dir)

3>Once again install gem-0.9.5

4> Now ur problem get solved