The specified CGI application misbehaved by not returning a complete set of HTTP headers
March 16, 2009
By default WordPress uses a query string to identify a post. This is neither search engine friendly nor human friendly. A better way is to use a custom URI to better identify your posts.
Default word press url structure: /?p=1
Customized post url can be as follows:
/index.php/2009/03/sample-post/
/index.php/archive/sample-post/
When you try to change default url of wordpress then you may got an error something like “The specified CGI application misbehaved by not returning a complete set of HTTP headers“.
This error generated because you change the default behaviour of url implementation on IIS for PHP and there were no extension to handle that request. PHP can process customized url but by default; it can not. You have to modify php.ini to use custom url.
Step 1: Generate new php.ini file and place it into your root directory.
Step 2: Modify newly generated php.ini and write following two lines.
cgi.fix_pathinfo = 1
cgi.force_redirect = 0
You’ll create new php.ini for each domain or sub domain that is using custom url structure or if you have access to modify php original ini file then you only modify that and you do not need to create new php.ini file for each domain or sub-domain.
Happy Coding
Posted in 
(6 votes, average: 4.33 out of 5)
content rss
March 17th, 2009 at 1:39 am
Its really work. Great job saqib.
Thanks
March 17th, 2009 at 8:41 am
Thanks God, I got the solution of my CGI error. Thanks you Saqib for your great work.
March 17th, 2009 at 10:38 am
[...] bookmarks tagged engine The specified CGI application misbehaved by not re… saved by 2 others kewlAkane bookmarked on 03/17/09 | [...]
March 17th, 2009 at 6:43 pm
is it really working? Can i include php.ini in my own website and IIS can also handle this file?
If so, it is cooooooooooool.
March 30th, 2009 at 2:20 pm
Nice website, I found you while looking for some blog related search and want to give you a compliment while I was here.
April 19th, 2009 at 7:54 am
Thanks Hellen
June 15th, 2009 at 9:11 am
Great post! I’ll subscribe right now wth my feedreader software!
September 13th, 2009 at 12:23 am
Life Saver .. Searched for Days
php working now
November 2nd, 2009 at 2:27 pm
Cool, I struggled with this problem for a week, tried everywhere on the web to get it sorted. Almost gave up!. Thanks so much!!!!!
January 4th, 2010 at 9:02 am
Where is the php.ini file located?
January 7th, 2010 at 8:44 pm
You have to create new text file and put given 2 lines in that file and upload it to root directory of you website with name with “php.ini”.
February 5th, 2010 at 2:31 pm
I was trying to increase the maximum file upload size and post size with a custom php.ini and had this same error you are talking about here. I tried those 2 lines you have suggested in my custom php.ini and it worked. I find this strange,any ideas on what could be the reason?.
Thank you for the article though, I bet it saved me from a headache:)
December 8th, 2010 at 5:18 pm
Hey, i think you visited my website so here i am!.I am looking for ways to add things to my blog!I suppose its ok to use some of your ideas!!
January 31st, 2011 at 12:46 pm
Nice piece, I am a big believer in leaving comments on blogs to help the blog writers know that they’ve added something useful to the innertubes!
January 31st, 2011 at 9:52 pm
Hi , I have installed IIS 5.1 and I have created a simple html page to run a exe file, I have generated this exe from bat file with converting tool.But when I am running exe from ISS , its giving “The specified CGI application misbehaved by not returning a complete set of HTTP headers” I have also created this php.ini in wwwroot, but nothing works. Can you help me what else i can tried.
br//
Aakash Mishra
February 22nd, 2011 at 4:27 pm
Hi Aakash,
This tricks only help those who want to rewrite url in php. In your case, i think you must assign execution rights on your file.
Thanks