“FREE” WordPress Themes – Base 64 encoded footer

I was looking at some free WordPress themes today for a little project I’m working on. I’m fairly careful about what I run on my servers so I checked through the source quickly before even considering looking at them. It is amazing how many of these “Free” themes contain links to interesting places and other interesting things like Base 64 encoded sections.Β  Most of the time these sections are harmless but there is no way I’m going to run something on my server until I have seen what it’s doing.

Example:

eval(base64_decode('Pz4gPC9kaXY+IA0KPGRpdiBpZD0iZm9vdGVyIj4gDQogIDw/cGhwIHdwX2Zvb3RlcigpOyA/Pg0KICA8ZGl2PiAmIzE2OTsgPD9waHAgZWNobyBkYXRlKCdZJyk7ID8+IA0KICAgIDw/cGhwIGJsb2dpbmZvKCduYW1lJyk7ID8+DQogICAgICA8P3BocCBpZihpc19ob21lKCkpIDogPz48YSBocmVmPSJodHRwOi8vMWFjbmVtZWRpY2F0aW9uLmNvbS8iIHRpdGxlPSJBY25lIHRyZWF0bWVudCAiPkFjbmUgdHJlYXRtZW50IDwvYT48P3BocCBlbmRpZjsgPz4NCg0KICAgIDxkaXY+PC9kaXY+IA0KICAgIDw/cGhwIHdwX2xvZ2lub3V0KCk7ID8+IC4gDQogICAgPD9waHAgd3BfcmVnaXN0ZXIoJycsICcgLicpOyA/Pg0KCTw/cGhwIGVjaG8gZ2V0X251bV9xdWVyaWVzKCk7ID8+IHF1ZXJpZXMuIDw/cGhwIHRpbWVyX3N0b3AoMSk7ID8+IHNlY29uZHMuDQogIDwvZGl2Pg0KPC9kaXY+DQo8L2JvZHk+DQo8L2h0bWw+DQogPD8='));

So I had to work out how to rid myself of these things and thought others might like to know where to find information on how to do the same. The FAQ, How to get rid of encoding in a theme’s footer? explains how to get rid of that coding but also has links to topics that will help you.

I personally found the following site very useful though: http://home2.paulschou.net/tools/xlate/ just past the coding in there and play around πŸ˜‰

More on redirecting with Mod_Rewrite

So it’s all well and good to redirect from one domain to another but how about redirecting to a directory?

I use shared hosting and host 3-4 domains on the same hosting account. To be nice and tidy I like to keep each site in a separate sub folder. There are a few ways I could do this obviously. I could use PHP and do something like the following:

$SiteNameURL = $_SERVER['HTTP_HOST'];
switch (strtolower($SiteNameURL)) {
case "domain.com": //MUST BE LOWER CASE
            header("Location: http://" . $_SERVER['HTTP_HOST'] . "/folder/");
            break;
case "www.domain.com": //MUST BE LOWER CASE
            header("Location: http://" . $_SERVER['HTTP_HOST'] . "/folder/");
            break;
}

But that is rather ugly and it would be nice to keep all the redirecting in one place.
This is what I came up with:

#Turns the rewrite engine on.
RewriteEngine on

#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

#www.domain.com and domain.com will map to the folder {root}/folder1/
RewriteCond %{HTTP:Host} ^(?:www\.)?domain\.com$
RewriteCond %{REQUEST_URI} !^/folder1/
RewriteRule ^(.*) folder1/$1 [NC,L,NS]

There is a little bit of regex involved but if you step through line by line it’s really fairly simple. Of course the last 4 lines are what matters for me. I added them to my “.htaccess” file from my first post on Mod_rewrite.

Redirecting from one domain to another domain with Mod_Rewrite

Lets get started with some of the things I’m doing while I setup this site and a few others I’m working on. First thing I needed to do was redirect a few domains elsewhere as this shared web hosting is used for some domains I look after for someone else. I can’t be bothered getting the DNS changed so to so I’m going to use mod_rewrite to redirect to the domain that is in use.

So here is what I found.

So if you need to change an existing website to another domain name your web server is using Apache HTTP Server then you can use the mod_rewrite module to do the task. I used something along the lines of the following code:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^OldDomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.OldDomain.com$
RewriteRule ^(.*)$ http://www.NewDomain.com/$1 [R=301,L]

Add this to the existing β€œ.htaccess” file or add a newβ€œ.htaccess” file in your OldDomainβ€˜s web root folder(example: /public_html/).

Done! Now all visitors to OldDomain.com(regardless the path) will auto redirected to NewDomain.com(with appending path).

For those of you who don’t want to fiddle with the “.htaccess” file you could just use PHP as follows:

$SiteNameURL = $_SERVER['HTTP_HOST'];

switch (strtolower($SiteNameURL)) {

case "domain.com": //MUST BE LOWER CASE
            include 'page1.php';
            break;
case "www.domain.com": //MUST BE LOWER CASE
            include 'page1.php';
            break;
case "yourotherdomain.com": //MUST BE LOWER CASE
            include 'page2.php';
            break;
case "www.yourotherdomain.com": //MUST BE LOWER CASE
            include 'page2.php';
            break;
default:
            include 'other.php';
}