mod_rewrite on Apache 1.3

Posted on 2006-04-13
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
    LVL 27

    Accepted Solution

    > 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

    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

    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

    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.
    LVL 5

    Author Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    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 …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now