Forum Moderators: phranque

Message Too Old, No Replies

.htaccess and <FilesMatch>

         

SyntheticShield

3:04 am on Dec 25, 2005 (gmt 0)

10+ Year Member



Hello all. Im trying to install a .php based counter on my website. Seemed easy enough until I realized it wouldnt work with .html files. The place that created the counter (bbclone) had a section dealing with this and suggested using .htaccess to address this issue. They provided the following code:

AddType application/x-httpd-php .htm .html <FilesMatch "\.(html?)$"> php_value short_open_tag "Off" php_value auto_append_file "/the/path/that/leads/to/count.php" </FilesMatch>

The idea was to creat the count.php file, upload it and point the .htaccess file to it and it would 'copy' the php code to all the .html files and that in conjunction with the AddType line to parse .html files it would allow the .htm and .html files to work with the .php counter.

Okay, now that Ive told you probably what you figured out by just looking at the code, on to the issue. When I upload the .htaccess file, my site is no longer accessable and I get the Internal Server Error message.

I know what the full server path is and Ive used that and still get the same thing. So my next assumption was that maybe it was a syntax error or something but I dont know enough yet about the code used to be certain. I went to the website that made the program and they have fourms there and found nothing. I contacted the programmer and have recieved no response and thats fine Im sure they get bombarded with requests for help.

So I came here to see if I can find some direction or help. If I include only the AddType I get no error. So to try and troubleshoot some more I added a simple ErrorDocument line:

ErrorDocument code 404 /path/to/404.html

I type in an address I know doesnt exist on the site and oddly it doesnt send me to the error page. The host is using Apache 1.3.33 so its fairly current.

I printed out a guide on using the .htaccess file but havent found anything to clue me in yet as to the trouble. So having done what thought might work and still with the same issue I hope that someone here can help out.

I appreciate in advance any assistance.

Key_Master

3:21 am on Dec 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It can't be all on one line and no need for "code" in the ErrorDocument. Try it like this:

AddType application/x-httpd-php .htm .html
ErrorDocument 404 /path/to/404.html

<FilesMatch "\.(html?)$">
php_value short_open_tag "Off"
php_value auto_append_file "/the/path/that/leads/to/count.php"
</FilesMatch>

SyntheticShield

3:43 am on Dec 25, 2005 (gmt 0)

10+ Year Member



Thank you, Im going to try that out. Amazing how something so simple can cause so much havoc.

SyntheticShield

6:54 am on Dec 25, 2005 (gmt 0)

10+ Year Member



Well, after separating the lines, at least Im not getting the 500 Internal Server Error now. So thats good. However, nothing is working. My understanding is that the FilesMatch section was supposed to take code in count.php and add it to any .htm or .html file and then the AddType would set Apache to parse that out. In other words the code in count.php would be added to all html pages and it would be read thus making the PHP counter work. Am I getting that much of it right?

Next, the error document isnt working. Im new (obviously) to .htaccess files so Im pretty much cuttin'-n-pastin' here but trying to read over and learn too. I can pull it up if I type the address to it directly in the browser so its web accessable. So Im not sure whats going on there.

AddType application/x-httpd-php .htm .html

AddHandler server-parsed .htm .html (<---didnt know if I would need this or not)

<FilesMatch "\.(html?)$">
php_value short_open_tag "Off"
php_value auto_append_file "/path/to/my/file/count.php"
</FilesMatch>

ErrorDocument 404 /path/to/my/error pages/ErrorPages/404.html

Here is the link to the instructions for the counter in case Im missing something. Im at a loss for why this wont work but I would appreciate any assistance. Thanks.

[scriptsearch.com...]

Key_Master

3:31 pm on Dec 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll have to bring the issue to your host. The httpd.conf needs to be modified to allow the .htaccess file to override the settings in the httpd.conf file.

SyntheticShield

4:26 pm on Dec 25, 2005 (gmt 0)

10+ Year Member



Ahhh, okay, well I appreciate it, I'll see what they will do for me.