httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Hodo <>
Subject [users@httpd] mod_rewrite problem with cgi-bin pages`
Date Wed, 08 Feb 2006 18:55:44 GMT
I was revamping a website to use SSI, and changed all of the default pages to .shtml.

I wrote an htaccess file (based upon the  Apache 2.0 URL Rewriting Guide example "Backward
Compatibility for YYYY to XXXX migration") to do the following:
-check to see if a file was of the format ^(.*default)\.html$ : does the requested file end
with "default.html"
  -if so, check to see if there is a file in the same directory with the same name but a .shtml
    -if there is, rename the request to .shtml
    -if not, permanently redirect the link to /404.html

This would prevent users from accessing old pages (of which there are about 400), and send
them to the new pages if they existed, or redirect them from any discontinued default pages.
I can then, at my leisure, delete the old default pages. All other requests (including cgi-bin's)
should process normally. 

However, when the htaccess file is placed in the webroot, any request to a cgi-bin file returns
a 403 "forbidden" message. When it's removed, access is allowed.

My htaccess file is as follows:
RewriteEngine on
RewriteBase /
#  1. parse out basepath & 'default', remember the fact that url had .html in WasHTML
RewriteRule   ^(.*default)\.html$              $1      [C,E=WasHTML:yes]
#   if document.shtml exists
RewriteCond   %{REQUEST_FILENAME}.shtml -f
#  2.		rewrite to default.shtml , redirect, skip following rule
RewriteRule   ^(.*)$ $1.shtml                   [R=permanent,S=1]
#   else if WasHTML
RewriteCond   %{ENV:WasHTML}            ^yes$
#  3. 		 redirect to 404.html
RewriteRule   ^(.*)$ /404.html [L,R=permanent]

ErrorDocument 404 /404.html
Does anyone have an idea as to why this htaccess file does not allow cgi-bin access? 
I haven't been able to figure it out.

Bruce Hodo - Webmaster, GetAwayNetwork, Inc.
     ==Providing unique vacation information on the World Wide Web==
       For Villas, Resorts, Hotels, Air/Hotel Packages, Charter Airfares
=============== Visit us at ===============

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message