Subscribe RSS

Archive for July, 2009

Screen Jul 07
Aww isnt that cute! BUT ITS WRONG!

Hay look another irrelevant picture!

There is a very useful application with plenty of features that can be downloaded easily.

One of the best features is the ability to start a screen session in ssh from one location, disconnect it then reconnect it at a later time from a different session.

Get it now: aptitude install screen

As it is to be used in console and key commands need to be passed to the bash session that it contains the key commands can be quite complex.

As rule of the thumb all commands start with ^A that is control + a then let go followed by a key or combination of keys. You can get a full list of commands available by pressing ^a + ? in screen.

Create window ^a +c
Close window “exit” no prior key seq.
Go to window 0 ^a + 0
Go to window 2 ^a + 2
Go to last window ^a + ^a
View list of windows ^a  + ” (yes quote marks you’ll need to press shift too)

I could go on but this is it in a nutshell.

Category: Linux  | Tags: , , ,  | Leave a Comment
ModRewrite: File existance check Jul 01

We have written about mod_rewrite before, but did you know that you can check if a file (or directory) exists before you attempt to redirect to it? Here’s how:

RewriteCond %{DOCUMENT_ROOT}/files/%{REQUEST_URI} -f
RewriteRule ^/([^/]*)$ /files/$1 [PT]

The RewriteCond checks for the existance of a file in the specified path, this is done with the special mod_rewrite rule -f. If you want to check if a file does not exist, you could use the following:

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f

Also, you can check for the existance of a directory with ‘-d’

The results of the above rule will allow the user, when they visit the URL

http://example.com/foo.html

to instead be served:

http://example.com/files/foo.html

so long as /files/foo.html exists. If it doesn’t, the usual behaviour will occur (such as other rewrites/redirects running, or causing a 404 error to be displayed).