Are these okay in a .htaccess file?

I’ve seen the below in someones .htaccess file. How important are they please? Does the hash at the beginning mean something? If so, why would there be 2 on 1 line?

#php_flag allow_url_fopen On
#php_flag allow_url_include On
#php_flag allow_url_fopen 1
#php_flag allow_url_include 1
##php_flag display_errors On
#php_flag display_errors Off

The hash sign comments them out, so they are serving no useful purpose as they stand.

1 Like

Thanks Gandalf, but why would there be 2?

A typo most likely. My guess is it was already commented out and the person just added a hash in front of all the directives, so that one ends up with 2.

Yes, it doesn’t really matter much. Everything after the first one in a line is a comment.

I don’t know what Apache means by “flag” - log the info? I would do the settings in the php.ini file eg. (note, the semi-colons start comments)

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = Off

; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = Off

Further details fro @craig buckler


Thank you very much for the help on this, so is it okay to have any/all of these in the .htaccess file, or should any/all of them be in the php.ini ?

If you can get at your ini file, which often isn’t possible with a shared host.

But you may not need them in htaccess either, take a look at a php_info() file and see if you need to first.

IMHO make the file, look at it, and take it down.

I have access to my .htaccess and my php.ini

Is it better to have any/all of these in the .htaccess file, or is it better to have any/all of them in the php.ini ?

php_flag allow_url_fopen On
php_flag allow_url_include On
php_flag allow_url_fopen 1
php_flag allow_url_include 1
php_flag display_errors On
php_flag display_errors Off

They’re better off in the php.ini IF you need them at all. However, you don’t want BOTH

php_flag display_errors On


php_flag display_errors Off

One or the other. On for your localhost when your testing/debugging. Off for live.

Thank you Gandalf. Out of curiosity, why are they better in the php.ini rather than the .htaccess please?

I’m sure someone can explain better that I can, but the php.ini file is processed less frequently than the .htaccess file so it’s more efficient.


A post was split to a new topic: 301 redirect in .htaccess

Thank you.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.