RSS Feed!

About me

I am a business intelligence developer working at Bizware since August 2015. In this blog I will present code samples, primarilly in tsql but also findings in all other parts of the Microsoft BI-stack.

Disclaimer: All code should be considered as "as-is", i.e. badly tested and not working until extensive testing have been made by anyone reading the code. :)

Happy coding!

Posts Tagged ‘Apache’

Solution to “Cannot modify header information – headers already sent”

Sunday, November 15th, 2009


This problem seems to occur on a frequently acting basis, so I’ll try to make a summary of the several solutions you can find on the net here:

Solution nr 1: Trim whitespaces near your start-tag in php, so it looks like this:

/* After trimming whitespace, write out your header and the rest of your code */

Solution nr 2: header() is coming after require/include

/* Try to make requires/includes compile after header */

//code here

3. Or the pandoras box-solution: change the coding of the current file from UTF-8!
Sometimes (I don’t know for what reason) apache can’t read UTF-8 properly and think of the start-tag as other characters.

#1: Open your file in a text editor (i recommend notepad++ or notepad)
#2: Change the coding of the file from UTF-8 to ANSI.
#3: Save and upload it to the server again.

That’s summarises the top 3 solutions for this type of problem. There’s probably more solutions, but in order to find them, you need to dig deep into the search engines.

A newbie guide to understanding the basics about .htaccess and mod_rewrite

Sunday, November 8th, 2009


This will be my first post in english at my blog! Yay!

Anyways, after stumble accross the net for some good guides and info about .htaccess and mod_rewrite I finally found some good sorces for info.

So what is mod_rewrite and .htaccess?

mod_rewrite is a configuration you can do in your httpd.conf file, the configuration tells the server what to activate and deactivate. If you enable mod_rewrite, you could set a lot of configuration options when it comes to how the client “reads” your domain. In 99% of the cases of the default settings, this is on. If your server is local, it will be off.

To turn it on, you need to find mod_rewrite and sometimes you need to find it twice in httpd.conf, it all depends what kind of settings you have.

How to enable it

A tip is to use the search function in wordpad or some other text editor to find the correct line of code. In wordpad, notepad or open office – use CTRL + F in httpd.conf.

When you find it, it looks like this:

#LoadModule rewrite_module modules/

Throw away the #, and restart your server.

If you’ve done this, create a file named “servertest.php” and write and scroll down to mod_rewrite (CTRL+F). Did you find it? If not, go through these guides:

Hey, what about .HTACCESS?

Yes! When mod_rewrite enabled, you could extend the list of funny stuff you can do in .htaccess! This file is sacred, for many reasons it’s your magic wizard book.

This file makes the rules recursive, i.e. if you put it in your root-folder, every folder under it will get the rules you write in .HTACCES in your rootfile (i.e.

In .HTACCESS you could specify a lot of stuff to happen for the client:

  • You could disable the user to gain access to some/all of your files.
  • You could write smart URLs.
  • You could specify how a file should be viewed (MIME-type etc.)

And a lot of more fun, go to one of the following guides to know more about your specific need!

High-rated guides for newbies:

I’d like to recommend this guide to understand how to write smart urls. The guide is thorough and in-depth how you could use it. It also shows you how to use flags, a primer to the hard-to-understand regular expressions and lists server variables you can use.

This guide is also an excelent tutorial on security issues, if you want to disable script-kiddies, bots and other intruders. I highly recommend it.

I’m lazy, fix it for me directly!

If you just want smart urls, there are two ways to fix it:
By a generator,
Or by specify it by a pHp-class (1) and (2)

Other resources:

The official apache guide, although it was too technical for me with quite bad examples

This is a fairly good guide, it brings up some decent examples, but aren’t as thorough as the previously mentioned guides.