Todays .htaccess tip – How to get rid of the www. subdomain

#www. is overrated
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)  http://%1/$1 [QSA,L,R=301]

Now let’s explain how this works:

The first line is a comment, that explains what the rewrite is supposed to do.

This line just turns on the rewrite engine

RewriteEngine On

This line says if the domain is “www.anything” and note that it saves the domain without the www. part as %1

RewriteCond %{HTTP_HOST} ^www\.(.*)

now this line does the actual rewriting. from anything to the domain with the query string attached (QSA) so we won’t break links. also note that it is a permanent redirect (the R=301 part) and it’s the last rule (L) that will be executed for this request.

RewriteRule ^(.*)  http://%1/$1 [QSA,L,R=301]

Eine Kleinigkeit für Lisa

#!/usr/bin/env python
#für dat Lisa

def stuff(quest):
    from random import randint
    num = randint(0,len(quest))
    return quest[num]

def main():
    quest=["huuunger!",
           "Will spielen",
           "du bist doof"
           ]
    print("Ich bin das baby du musst mich lieb haben!")
    while 1:
        input = raw_input(stuff(quest))
        if input == "stirb":
            print("du mörder!")
            raw_input()
            break
if __name__ == '__main__':
    main()

A little something for my GF


#!/usr/bin/env python
'''
This is made for my wonderfull girlfriend.
'''
try:
    import psyco
    psyco.full()
    import random
except:
    import random

def getBooks(file):
    import os
    f = open(os.path.join(os.path.curdir,file),'r')
    books = []
    for line in f.readlines():
        books.append(line)
    return books

def shuffel(books):
    num = random.randint(0,len(books)-1)
    result = books[num] + ", Number of books in list %s" %len(books)
    return result

def main():
    print(shuffel(getBooks('books.txt')))
    raw_input()

if __name__ == '__main__':
    main()

Hello World

if user == nice:
    print "hello World"
else:
    print ":=("