...

View Full Version : adding an exception to .htaccess for addhandler modifications



ptrcao
01-17-2011, 06:45 PM
currently .htaccess in my root reads:



AddHandler application/x-httpd-php .php .html .htm
AddHandler x-httpd-php5-cgi .html


I need to create an exception for the /stats/ directory

the context to this problem can be found, well-articulated at:

http://blog.ericdaugherty.com/2009/11/embedding-php-in-html-files-and-godaddy.html

Fou-Lu
01-17-2011, 06:55 PM
.htaccess is directory context aware; can you not just create another .htaccess in your /stats/ directory that remove those handlers (RemoveHandler)?

ptrcao
01-17-2011, 07:03 PM
.htaccess is directory context aware; can you not just create another .htaccess in your /stats/ directory that remove those handlers (RemoveHandler)?

hello fou-lu. apparently a violation of godaddy's policies? i spoke to a godaddy customer rep who seemed to frown on it.

Moreover, Dougherty at http://blog.ericdaugherty.com/2009/11/embedding-php-in-html-files-and-godaddy.html seems to allude vaguely to this not being an option

This would be a simple fix if I could edit the .htaccess file in the stats directory. I could simply override the .html handler back to the default, and avoid the PHP processing.


is there no exception line i can add to the .htaccess file in my root?

Edit: the problem is the directory itself is reserved by godaddy and they don't like it when you modify anything inside it.

Fou-Lu
01-17-2011, 11:51 PM
I'm not sure if .htaccess can handle the <LocationMatch or not. If it does, you should be able to wrap the addhandler around this: <LocationMatch "(?!/stats/?)$">AddHandler stuff</LocationMatch>. It it doesn't I'm not sure there is a way to work that out.
Make sure you have the godaddy team provide you with documentation of where it says that its against their TOS. If they cannot, I'd consider that directory free game. I assume as well that the /stats is a url of yours under /home/user/public_html/stats, and not actually a root directory of /stats which would definitely make this forbidden (and useless since it would likely not be available to you).

ptrcao
01-18-2011, 04:04 AM
I'm not sure if .htaccess can handle the <LocationMatch or not. If it does, you should be able to wrap the addhandler around this: <LocationMatch "(?!/stats/?)$">AddHandler stuff</LocationMatch>.

I assume this means "if the location does not correspond to /stats/ then apply the add handler, right?

Also the stats directory is not of my own creation; it was automatically generated by GoDaddy for their statistics feature.

I don't want the server parsing any files in this directory, because it causes problems for viewing site statistics.

It is a folder in the root directory, created by GoDaddy. Does this answer your question of whether it is it a "root directory"?

Fou-Lu
01-18-2011, 05:12 AM
Not really no, by root directory I mean its actually under /, listed as /stats. If it is, chances are you cannot even read that directory, and if you can its likely shared by many other people.
Did that work in the htaccess? Yes, the pattern would say if it doesn't match /stats[/] then it would add the handler. I'm not familiar enough with apache patterns to know for sure if that will work though.

ptrcao
01-18-2011, 05:50 AM
Not really no, by root directory I mean its actually under /, listed as /stats. If it is, chances are you cannot even read that directory, and if you can its likely shared by many other people.
Did that work in the htaccess? Yes, the pattern would say if it doesn't match /stats[/] then it would add the handler. I'm not familiar enough with apache patterns to know for sure if that will work though.

I tried:


<LocationMatch "(?!/stats/?)$">AddHandler application/x-httpd-php .php .html .htm</LocationMatch>
<LocationMatch "(?!/stats/?)$">AddHandler x-httpd-php5-cgi .html</LocationMatch>

with no luck Fou-Lu.

Any other ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum