Archive for the ‘website’ Category

Moving WordPress from a sub-domain to a sub-path

Thursday, July 19th, 2018

Many years ago, it seemed a good idea to put the company blog to Well, things have changed. SEO und https-certificates now make look better.

Here’s how to make the transition (assuming the data mentioned above):

  1. Add this to your .htaccess file:
    RewriteEngine on
    RewriteRule en/blog/(.*)$ /blog_rewrite.php?$1
  2. Create a file /blog_rewrite.php with this content:
    function HandleAsRewrite($basepath, $blogurl)
      $domain = strtolower($_SERVER['HTTP_HOST']); // ""
      $scheme = strtolower($_SERVER['REQUEST_SCHEME']); // "https"
      $input = getenv("REQUEST_URI");
      if (substr($input, 0, strlen($basepath))==$basepath)
        $page = file_get_contents($blogurl.substr($input, strlen($basepath)));
        $replacement = $scheme.'://'.$domain.$basepath;
        $page = str_replace($blogurl, $replacement, $page);
        $page = str_replace(str_replace('/', '\\/', $blogurl), str_replace('/', '\\/', $replacement), $page);
        foreach ($http_response_header as $headline)
          header ($headline);
        print $page;
    if (HandleAsRewrite('/en/blog/', ''))
    print "not found";
  3. Optional: Edit the wordpress template’s header file and add:
    <link rel=”canonical” href=”<?php echo $_SERVER[‘REQUEST_URI’];?>”>

If you want to handle more than one blog, simply duplicate the “if (HandleAsRewrite” and the htaccess-entry.

Limitations: The script won’t handle POST data.

Next > Weiter > Siguiente >

Saturday, April 10th, 2010

When doing screenshots of your software you may face some problems with the buttons in wizard and property sheet dialogs. The buttons at the bottom of these dialogs are drawn by Windows, with the language of your Windows installation. That can differ from the language of your application. The result doesn’t look professional. An English dialog with (for example) German “Zurück” / “Weiter” buttons (instead of Back / Next) won’t impress the customers.

You should of course correct this with an imaging application. And to make this easier I made a collection of the usual wizard buttons to copy/paste in

  • English, German and Spanish
  • Enabled, Disabled, Highlighted
  • NT, XP, Win7 Style

Feel free to use them.

Download WizardButtons_Devblog.png (33k)

Using for promotions

Monday, March 29th, 2010

When doing a promotion or sending links by e-mail, it’s nicer to have short, speaking links like instead of the normal link monsters. You might implement this on your server as folder name (polluting your folder structure) or use the htaccess file (where a mistake can kill the entire server).

But I suggest a simpler solution: Use a 404 error page script.

Most hosting companies allow you to specify a custom 404 (“not found”) error page. This page can also be a script. And the script can check if the requested URL is your promotion code and then redirect to your real page.

This can also keep you from typing (or writing on paper) long product URLs. I have set up shortcuts for all my products. If I want someone to have the link of the 1-Click Duplicate Delete for Outlook page, I can simply write this link:
Instead of:
(Which is so long that some mail clients print into 2 lines, effectively breaking it.)

Here’s the PHP script for that:

if (getenv("REQUEST_URI")=='/1cddo')
 header ('Location:

Using Google to protect your site

Sunday, November 29th, 2009

Is your website error free?

My site  has grown over the years and uses a lot of PHP code. It’s difficult to test each and every aspect of it. Here are 3 simple tricks that can help you test your website. They don’t replace a real test (that you should do after a each change), but they’re a nice addition.

Trick 1:

Use Google to search your website for “error” or “warning”. You can use the format: (warning or error )

This of course has a terrible lag, since Google crawls your website only every few days or weeks, but on the other hand Google may use different parameters or aspects that you use in your own tests.

The real fun comes with combination of trick 2.

Trick 2:

Use Google alerts to automatically search your website for problems. You can create a free Google alerts account and use the search mentioned above to have Google automatically check your site every day. If something breaks, Google will send you an e-mail.

Trick 3:

Same as above, but use your Google to watch your site for hacked pages. A hacker might have exploited a weakness in your server and created a new page for whatever product he promotes with his spam mails. You probably don’t want to become involved with this. So instead of using “warning or error” in the search. use a list of the usual phrases and medical products that the spam mails usually contain.

It’s a one-time work of a few minutes. The rest of the work is done automatically by Google and can save you a lot of trouble.