kentang
(Kentangditaman)
1
dear master,
i have problem with urlManager. i want to remove index.php. But i have problem to catch variable $_GET after i remove it. Below is my controller.
class CobaController extends Controller
{
public function actionIndex(){
echo "runaction";
if(isset($_GET['var1'])){
echo $_GET['var1'];
}
}
}
i have set my urlManager like below
‘urlManager’=>array(
‘urlFormat’=>‘path’,
‘showScriptName’=>false, //menghidden index.php
when i access with index php. it is no problem
url : localhost/store_permalink/index.php/coba/index?var1=value
output : runactionvalue
but when i access wuthout index.php. it is problem
url : localhost/store_permalink/coba/index?var1=ok
output : runaction
Thanks for help
softark
(Softark)
2
[color="#008000"]/* Moved from "Bug Discussions" to "General Discussion for Yii 1.1.x" */[/color]
Hi kentang, welcome to the forum.
Post your rules for urlManager, in order to see what’s happening.
And please use ‘code’ tag in your post to format your code … ‘<>’ button is for ‘code’ tag.
kentang
(Kentangditaman)
3
halo softark,
this is my urlmanager.
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false, //menghidden index.php
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
Thanks for reply
softark
(Softark)
4
Hmm, I don’t see anything strange.
Would you please try this to see what’s going on?
public function actionIndex(){
// echo "runaction";
print_r($_GET);
if(isset($_GET['var1'])){
echo $_GET['var1'];
}
}
}
kentang
(Kentangditaman)
5
Below is the result
url : localhost/store_permalink/index.php/coba/index?var1=value
result : Array ( [var1] => value ) value
url : localhost/store_permalink/coba/index?var1=value
result : Array ( [/coba/index] => )
softark
(Softark)
6
Ah, you are getting $_GET[’/coba/index’].
I’m not sure, but it seems like your Apache (or nginx?) config might have some problem.
kentang
(Kentangditaman)
7
I am sory can’t reply directly, because i new member so can’t send 3 message. I already found the problem. The problem is my .htaccess file.
Thanks for help