Apache

Enable Mod Rewrite Error Log

1 min read

Just a quickie - throw this in your apache config if you need error logging for mod_rewrite. Useful in a dev environment, not so much in production.

RewriteLog /var/log/httpd/rewrite.log RewriteLogLevel 9

apache
Read more

Using mod_rewrite with VirtualDocumentRoot

1 min read

In our dev environment, we use VirtualDocumentRoot to avoid configuring new environments when we get a new developer. It’s awesome.

However, if you try to use mod_rewrite, you’ll find that your rewrite rules will prepend whatever you have defined as the document root in the config file. To get around this, you have to use the PT (passthrough) flag, which will solve the issue.

Example:

RewriteRule ^/photo/(.*) /open.php?id=$1 [L,NE,PT]

Found here, on an apache archive.

apache
Read more

Enabling Mod Deflate in Apache

1 min read

I got an error while compiling Apache today:

“./configure”
“–enable-auth-digest”
“–enable-deflate”
“–enable-rewrite”
“–enable-so”
“–enable-vhost-alias”
“–disable-userdir”
“–enable-mime-magic” \

configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

I fixed this by installing zlib from source.

apache
Read more

'Apache: Urlencoded slash breaks multiviews?'

1 min read

If you have a URL like the following, and you’re using multiviews:

/login/15/return_page%2F50

it won’t work. FYI, the last part is a return page. In this instance, lets just pretend it’s a return page that’s supposed to get hit after a successful login.

Using Apache 2.2.3.

apache
Read more

Motorola RAZR and 406 Not acceptable

1 min read

In trying to get a site working on cell phones, I got a “406 Not acceptable” only on the Motorola RAZR. The site loaded fine on my Treo 755 and every Blackberry I’ve tried.

It seems that the RAZR doesn’t handle Multiviews very well, or at all for that matter. If you’re using Multiviews and Apache, you’ll have to specify the full URL: so /login.php rather just /login.

apache mobile php
Read more

Apache Compile Error

1 min read

I got this while recompiling apache (2.2.4).

configure: error: Cannot use an external APR-util with the bundled APR

After searching around for a while, I found a tip here to include this in my configure:

--with-included-apr

Built on MacOS X 10.4.

apache linux
Read more

10 (very) Basic Tips for PHP Web Application Security

2 min read

Barebones list for the things you should be looking for when developing a web app in PHP. Some of it applies to all web apps, not just PHP.

  1. Use HTML_Safe (or a similar javascript stripping library) to check for and remove javascript when you’re accepting data that will be output to a page.

  2. Check every get and post variable for validity.

Every web site has url like “dosomething.php?id=3”. Make sure that id you’re accepting is actually a number (or whatever type you’re allowing).

apache php tips
Read more

What caused that load spike?

1 min read

Every now and then, we find that we will have a sudden increase in the number of apache processes, load average will spike up, and then go back down to normal. In rare cases, we will see the same thing happen, and the load avg spike WAY up, all queries appear locked up, and the server must be rebooted. I am looking for ways of determining what caused this. I should note that it happens extremely rarely, and has never shown up in a load test.

apache linux mysql
Read more

Pretty URLs using Multiviews

2 min read

I saw a post on digg.com about how it’s nice to have “pretty urls” that are easy to tell people. While i’m not sure anyone would remember rustyrazorblade.com slash some ridiculous post name, it’s nice to have for search engines. Unfortunately, it didn’t really go into detail about how to accomplish the urls. A lot of people suggested mod_rewrite. Yes, it’s something you can use, but kind of a pain to set up.

apache php tips
Read more