When trying to follow a tutorial such as http://www.developer...0330/page1.html , one notices they employ the Apache ForceType directive to achieve static URLs together with mod_rewrite. As we have compiled PHP as a CGI/FastCGI on most servers, using the ForceType directive or anything similar would cause Internal Server 500 errors. We present a few tips/workarounds to ensure you get the intended effect, but one that is compatible with our system configuration
SOLUTION:
CASE #1) First, let's use an example. Say you're using the above tutorial link and come up to the place where the author talks about the following:
Excerpted from Jaisen Mathai, on developertutorials.com, said:
This will make sure that all requests to http://yoursite.com/article will send the file "article" to the PHP engine for parsing.
Let's try it! Make a file named .htaccess and put this in it.
Now make a file named article (yes, without an extension) and put this in it.
Let's try it! Make a file named .htaccess and put this in it.
<Files article> ForceType application/x-httpd-php </Files>
Now make a file named article (yes, without an extension) and put this in it.
<?php echo 'This thing works!!<br />'; echo 'Request_Uri is: '.$_SERVER['REQUEST_URI'].'<br /><br />'; echo 'This could come in handy!'; ?>
The above would actually produce an error since ForceType is not compatible with PHP compiled as a CGI with phpsuexec. Fortunately, the workaround below works superbly:
#enter in a .htaccess file #PHP as a CGI with Suexec .htaccess Style <Files article> SetHandler application/x-httpd-php </Files>
CASE #2) For our second example, let's say you want to edit a PHP configuration variable, such as upload_max_filesize to increase the file uploading limit. We can't use php_value in a .htaccess file, as we have PHP compiled as a CGI, which means Apache .htaccess edits won't affect PHP (and will actually cause errors). Instead, we would employ the php.ini method. Also take note that as opposed to a .htaccess file, a php.ini file needs to be placed in every directory and subdirectory that requires the altered directives.
; place in a php.ini file ; change file upload limit to 8MB ;;;;;;;;;;;;;;;;;;; upload_max_filesize = 8M; post_max_size = 10M;
This will increase the file uploading limit on your script (this case to 8MB), if it runs from the same directory where this php.ini file is located. For complex scripts, you'd usually place this php.ini file both in the public_html main directory, and /includes/ directory, if exists.
For Windows-based HostOptima servers, this is a bit different, and requires the following edit:
; place in a php.ini file ; change file upload limit to 8MB with fix (tested code on Windows/IIS servers) ;;;;;;;;;;;;;;;;;;; upload_max_filesize = 8M; post_max_size = 10M; cgi.force_redirect = 0; cgi.fix_pathinfo = 1;
The need for the above modification is complex, but only necessary in cases where the first method fails for some unknown reason.
NOTES: - If editing php config variables, you can also double-check to make sure the intended change was made successfully, by checking out a phpinfo script. Simply make a new .php file with
<? phpinfo(); ?>and this will display the PHP info output. Search for the config variable you modified, and if it's different than default, the change was made successfully.

Sign In
Register
Help

MultiQuote