Tuesday, 16 June 2015

Redirect internal links to another file with .htaccess

Redirect internal links to another file with .htaccess


Requirement:
When someone open http://domain.com/projectone.html, User should be able to see the same URL in Browser(i.e. http://domain.com/projectone.html). But Internally, application should call a file http://domain.com/projectone.php. But user should not get to know this.

Solution:
This is 100% achievable by .htaccess in single line.
But your application must allow and support the .htaccess.
RewriteEngine On
RewriteRule ^(projectone\.html)$  projectone.php [R=301,NC,L]


Following are the means of htacess flag used above.
R 301- means permanent redirect.
NC- means this rule is case -insensitive.
L- mens stop processing to next set, if the rule matches, no further rules will be processed.

Monday, 15 June 2015

Linux and Unix rm command help and examples

rm (short-name for remove) is a command used to remove objects such as files, directories, device nodes, symbolic links etc from the file-system. rm also remove the reference of objects. It works on Linux as well on Unix.


Linux and Unix rm command help and examples

In Actual, rm does not remove any object (file, directories and nodes etc), It just unlink the object from filesystem. That's why file system space may still contain leftover data from the removed file.

Following are rm commands with example.
Delete a single file.
rm filename



Delete all files [USE WITH EXTENSIVE CARE].
rm *



Delete all files which have .txt extension.
rm *.txt 



Delete all files which start with "data" text.
rm data*



Delete a folder (folder must be empty).
rm -d foldername



Delete all recursively. (d-directory, r-recursive).
rm -dr foldername



Delete a file forcefully and will not prompt.
rm -f  filename



Delete the files with prompt (d-directory, r-recursive, i-Prompt before every removal).
rm -dri foldername



Delete the files  without prompt (d-directory, r-recursive, f-without prompt).
rm -drf foldername



Delete the files with without prompt (d-directory, r-recursive, f-without prompt)
rm -drf foldername



Delete the files with single prompt (d-directory, r-recursive, I-single prompt)
rm -drI foldername



Delete the files with details (d-directory, r-recursive, v-explaination)
rm -drv foldername



Delete a file which exist in another folder.
rm /mnt/data/home/project1/public_html/filename.txt 



When we are using multiple options in command, see following:
1) We can exchange the position of option  (Make no difference)
2) We can also give "-" again each option parameter.
3) To Delete a directory recusively, Following commands are valid and are same.
rm -dr foldername
rm -rd foldername
rm -d -r foldername
rm -r -d foldername