Mod_rewrite not letting me use other directories

I have zenphoto installed in my main directory (/) with mod_rewrite enabled and everything works fine.

Now I'm trying to run a completely unrelated script in my cgi_bin directory (/cgi-bin) I tried editing the htaccess file so that all requests to localhost/p are directed to the cgi-bin directory but all I get is an object notfound error with the following text ...

I placed a simple gif in the cgi-bin and I try to request it by localhost/p/model.gif

`
The Zenphoto object you are requesting cannot be found.
Album: p
Image: model.gif
Page: index
`
I know basics of htaccess and this my current htaccess I added the bolded line ...

`
# htaccess file version 1.2.2.0;
# Update the above and the define in setup.php when you make changes to the rewrite rules!
# NOTE: Change the RewriteBase below to the absolute path to your zenphoto directory. (Or let setup.php do it for you!)


RewriteEngine On

#### !!! Change this to the web path (eg: http://www.yourwebsite.com/photos --> /photos) !!!
RewriteBase /
####

RewriteRule ^admin/?$ zp-core/admin.php [R,L]

RewriteRule ^p/(.+)$ cgi-bin/$1 [L] ##########
`
I read the mod_rewrite documentation and it seems to say that the L flag should stop all other processing so I'm not sure why it keeps processing after it matches the /p pattern. Any help would be appreciated, thanks.

Comments

  • acrylian Administrator, Developer
    Why don't you link directly? That should work, too.
  • Same error happens when I try to go directly except the error is ...

    `

    The Zenphoto object you are requesting cannot be found.

    Album: cgi-bin

    Image: model.gif

    Page: index

    `
  • You should not need to do anything to run a script in some other folder. (That is exactly how the admin backend runs.)

    The standard zenphoto .htaccess file will check to see if the page referneced by the URI is an existing file. If so it will just load that file. If the file is not found you will get the zenphoto 404 error.

    So the indication you are getting is that the .htaccess processing cannot find the target file.
  • Thats the weird thing its only the cgi-bin folder, I put another folder named c with the same model.gif file and I was able to access it.

    Any ideas as to what is happening in the cgi-bin that is causing this?
  • Probably access security on that file. It is not normal to directly link to scripts in the cgi-bin folder. Normally other scripts load resources from there.
  • Should I change the permissions or something they are already on 755? What can I do?

    Another thing I noticed is that it actually runs the file if it is a .pl (through log file) but it still displays the zp Object not found page.
  • I fixed this, for other who may have this problem ... try changing the .pl to .cgi ...
Sign In or Register to comment.