mod_rewrite on Apache 1.3

Posted on 2006-04-13
Medium Priority
Last Modified: 2010-03-04
I'm using the following in my /vnc/.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L]
RewriteRule ^(.*)                        index.php?url=$1 [L]

Now What index.php does is take the requested URL and repeat the request on a different port (which is running my VNC service) and then returns the data. Specifically it'll pass back a couple of java files to the web browser which will run a remote VNC client.

I'm having to do all of this because at work I'm behind a VERY restrictive firewall which will only allow traffic on port 80. Since I want a webserver too, I have to use an alternative to serve the files - hence my attempt at this modification.

The problem - The URL passed to index.php is always lowercase.

When requesting /vnc/VncViewer.class
the URL passed to PHP is /vncviewer.class which (of course) returns a 404 error. If I change the capitalisation manually, it works of course.

In case it helps, my PHP is below: (it's rough, ready, has no error checking, and does not currently filter out the HTTP Response headers but they're all problems for a later time!)

//header("Content-Type: Text/Plain");
if(isset($_REQUEST['url'])) {
       $url="/" . $_REQUEST['url'];
print "<H1>Server $socketHost Port $socketNum - URL $url</H1>";

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
   die("socket_create() failed: reason: " . socket_strerror($socket) . "\n");

$result = socket_connect($socket, $socketHost, $socketNum);
if ($result < 0) {
      die("socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n");

$in = "GET $url HTTP/1.1\r\n";
$in .= "Host: localhost\r\n";
$in .= "Connection: Close\r\n\r\n";
$out = '';

socket_write($socket, $in, strlen($in));

while ($out = @socket_read($socket, 2048)) {
//echo substr($response, $skipheader);
echo $response;


Ig anyone can PLEASE help (or even better, tell me a better way to do this!) I'd appreciate it. Thanks in advance
Question by:basiclife
  • 2
  • 2
LVL 27

Accepted Solution

caterham_www earned 1000 total points
ID: 16450818
> The problem - The URL passed to index.php is always lowercase.

So you're on windows? Try to ue the rules in your httpd.conf, if your request goes into a virtual host, place the rules into that virtual host and remove the .htaccess file:

RewriteEngine on
RewriteCond /full/physical/path/to/vnc/$1 !-f
RewriteCond /full/physical/path/to/vnc/$1 !-l
RewriteCond /full/physical/path/to/vnc/$1 !-d
RewriteRule ^/vnc/(.*)  /vnc/index.php?url=$1 [L]
LVL 10

Assisted Solution

sleep_furiously earned 1000 total points
ID: 16455039
See Apache bugzilla


Especially the comments:

"  This is resolved in Apache 2.0 - Apache 1.3 simply lowercased the filenames
  to 'canonicalize' them to their "one true name".  Yes this was very hackish,
  but that's the Apache 1.3 on Windows solution - an interesting and clever hack.

  Apache 2.0 was written from the ground up - and this was taken into account.
  The file's *true names* are used in Apache 2.0 (as stored on disk as their
  long file names.)  Also the "one true name", this takes a few more cpu/disk
  cycles but is more reliable and doesn't cause the sorts of problems you are

  Please upgrade to 2.0 to resolve your issue."


"As I said 15 months ago - it is simply NOT possible to straighten this
out in Apache 1.3/Win32.  Nothing has changed, or will change, in that
answer.  If you don't like the behavior (certainly I don't :-) then
upgrade to 2.0."

LVL 10

Expert Comment

ID: 16455117
caterham_www:  Just curious... I haven't tried out your solution, but wondering if the reasoning for moving it out of .htaccess is so that it doesn't go through the "add path-info postfix" and "strip per-dir prefix"?

LVL 27

Expert Comment

ID: 16455422
No, performance is one reason but an other one here is: I think the converting to lowercase is caused by apr while the request is being mapped to the filesystem (uri-to-filepath translation). In per-server context you're on the uri level. So the rule should match against an URL-path which is hopefully in its original case in this step of processing.

Author Comment

ID: 16479089
Thank you all for the rapid responses. The Apache 1.3 machine is just a local windows XP setup that I use for testing and I haven't run across this problem before. I'm at work now so will read through this more closely when I get home and see what can be done (if anything!) maybe have to upgrade to 2.0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question