PHP readfile() and large files

You may still have PHP output buffering active while performing the readfile(). Check that with: if (ob_get_level()) ob_end_clean(); or while (ob_get_level()) ob_end_clean(); This way theonly remaining output Buffer should be apache’s Output Buffer, see SendBufferSize for apache tweaks. EDIT You can also have a look at mod_xsendfile (an SO post on such usage, PHP + … Read more

Installing mod_wsgi on WAMP server running on Windows 7

These are the following things you need to do to setup Apache for Django. I assume you are using Python 2.7 (32-bit) on Windows (32-bit) with WAMP server (32-bits) installed. Download mod_wsgi-win32-ap22py27-3.3.so. Or download your respective .so compatible file Change its name to mod_wsgi.so and copy it to /Program Files/Apache Software Foundation/Apache22/modules on Windows. Open … Read more

Enable CORS with wamp on windows 8

I had the same problem and i solved it with these 3 steps: 1) in Apache config file (for me the path was C:\wamp\bin\apache\apache2.4.18\conf\httpd.conf) add the line: Header set Access-Control-Allow-Origin “*” in the content of the <Directory> tag: DocumentRoot “c:/wamp/www” <Directory “c:/wamp/www/”> Options +Indexes +FollowSymLinks Header set Access-Control-Allow-Origin “*” AllowOverride all Require local </Directory> 2) … Read more

RewriteCond to match query string parameters in any order

You can achieve this with multiple steps, by detecting one parameter and then forwarding to the next step and then redirecting to the final destination RewriteEngine On RewriteCond %{QUERY_STRING} ^category=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} &category=([^&]+) [NC] RewriteRule ^index\.php$ $0/%1 RewriteCond %{QUERY_STRING} ^subcategory=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} &subcategory=([^&]+) [NC] RewriteRule ^index\.php/[^/]+$ $0/%1 RewriteCond %{QUERY_STRING} ^product=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} … Read more

Apache’s ErrorDocument directive does not redirect

A few different mis-conceptions in the question. The following PHP code: header(“HTTP/1.0 500 Internal Server Error”); die(); Will never trigger an Apache error page – it’s triggering your browser’s default error page. Once control has been given over to PHP, it does not go back to Apache for error handling. ErrorDocument only works for error … Read more

RewriteRule checking file in rewriten file path exists

RewriteRule ^pages/([^/\.]+) cache/pages/$1.html [NC,QSA] # At this point, we would have already re-written pages/4 to cache/pages/4.html RewriteCond %{REQUEST_FILENAME} !-f # If the above RewriteCond succeeded, we don’t have a cache, so rewrite to # the pages.php URI, otherwise we fall off the end and go with the # cache/pages/4.html RewriteRule ^cache/pages/([^/\.]+).html pages.php?p=$1 [NC,QSA,L] Turning off … Read more