Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Make Apache parse regular HTML files for CGI's UNIX
If you use CGI's on your web pages (counters, etc.), then you've had to enable "shtml" processing in your httpd.conf file. Sometimes, though, you just want to stick a CGI counter on a plain boring HTML page. The standard solution is to rename the file with a .shtml extension so Apache will parse it. However, if you don't want to rename your files (as you'd then have to fix broken links from other pages), you can use the XBitHack flag in httpd.conf. Enter the following in your /etc/httpd/httpd.conf file:
XBitHack on
This directive tells Apache to treat any file that has the user-execute bit set as a server-parsed html document. So simply change the user 'execute' bit (chmod u+x filename.html) of any of the regular HTML files that you want parsed, and Apache will do the rest.

Remember to stop and restart the server for your changes to take effect. Note that I have not tried this yet on my Apache install, but this is basically right off the Apache documentation pages, so it should work as described.
    •    
  • Currently 2.00 / 5
  You rated: 2 / 5 (2 votes cast)
 
[3,023 views]  

Make Apache parse regular HTML files for CGI's | 3 comments | Create New Account
Click here to return to the 'Make Apache parse regular HTML files for CGI's' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Start/Stop...
Authored by: sharumpe on Oct 19, '01 12:14:13PM

There's a better way to make the server recognize changes - use the apachectl command like so:
/usr/sbin/apachectl graceful

This will do some error-handling stuff, as well as reloading the httpd.conf file. Of course, it assumes that you're doing things from the command line, which I suppose not everyone does. But if you do, try this instead.

Mr. Sharumpe



[ Reply to This | # ]
Can't this be done with AddHandler?
Authored by: foamy on Oct 19, '01 08:02:43PM

Search httpd.conf for
AddHandler server-parsed .shtml

and add

AddHandler server-parsed .html

You may need to include the following line like in the .shtml example
AddType text/html .html

I have .html parsed by the PHP interpreter or I would check myself to see if this works.



[ Reply to This | # ]
All vs specific?
Authored by: robg on Oct 19, '01 08:53:11PM

I'm a bit out of my league here, but I think the advantage of this method is that it won't parse ALL your HTML files -- if you don't set the execute bit, it's regular HTML; if it's excectuable, then it gets parsed. It's my understanding that there are overhead issues involved in parsing all the HTML files. It's better to parse just those files that require it.

But as I said, this is beyond my skills with Apache - any experts care to comment?

-rob.



[ Reply to This | # ]