Controller内のPOSTの値が消えてしまう。
使用しているミドルウェア
- apache2: 2.2.9
- CodeIgniter: 1.6.1
- PHP 5.3.2
CodeIgniter上で、以下のようなコードを動かしたところ、POSTの値が得られませんでした。
何かわかる方がいらしたら、教えていただけるとありがたいです。
下記に関して大まかなやりたいこととしては、
「cgiを実行できるパスに対してPHPで認証をかける」
ということです。
php
1class HogeController extends BaseController{ 2 function HogeController(){ 3 parent::BaseController(); 4 } 5 function cgi($executePath){ 6 var_dump($_POST);// array(0){ } 7 var_dump($this->input->post()); //bool(false) 8 $fp = fopen("http://127.0.0.1/cgi/$executePath"); 9 while(! feof($fp)){ 10 echo fgets($fp); 11 } 12 fclose($fp); 13 return; 14 } 15} 16 17class BaseController extends Controller{ 18 function BaseController(){ 19 parent::Controller(); 20 } 21 // 認証処理とか 22}
デベロッパーツール上でPOST送信が行われていること。及び、POSTの値が正常であることは確認できております。
cf.) POSTのフォーマット
[hoge]: 1
[fuga]: 60
[name]: "TrendData"
追記: CodeIgniterのディレクトリルートにある、index.phpに対し,var_dump($_POST)のコードを挿入したところ、
array(0){ }が出力されたため、原因として、
apacheの設定の可能性が高くなったため、以下にapacheのconfigで関係のありそうなところを記載させていただきます。
/etc/apache2/sites-enabled/000-default
ServerAdmin admin@localhost DocumentRoot /var/www/htdocs <Directory /> Options FollowSymLinks AllowOverride None DirectoryIndex index.htm </Directory> <Directory /var/www/htdocs> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from 127.0.0.1 </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn </VirtualHost>
/etc/apache2/conf.d/cgi-path.conf
ScriptAlias /cgi /usr/lib/cgi-bin/ Alias /cgi /www/htdocs <Directory "/www/htdocs/"> Options FollowSymLinks AllowOverride None Order Allow,Deny Allow From all </Directory>
回答1件
あなたの回答
tips
プレビュー