styleroom
(Styleroom)
January 20, 2012, 7:49am
1
Hello everybody!
I have a small question…
How to make URL without controller name?
Is it possible?
For example: I need this type of URL => http://domain.ru/page.html
[color="#FF0000 "]instead of[/color] http://domain.ru/controller/page.html
Could you help me, collegues?
p.s. I am sorry for my English…
styleroom
(Styleroom)
January 20, 2012, 8:47am
3
to Joblo
thaks a lot for your tips!
But I have already done URL without index file…
Now I need to get rid of the controller name.
I will follow your links
ivica
(Ivica Nedeljkovic)
January 20, 2012, 8:52am
4
Something like this could works:
'urlManager' => array (
'urlFormat' => 'path',
'caseSensitive' => true,
'showScriptName' => false,
'urlSuffix'=>'.html',
'useStrictParsing'=>true,
'rules'=>array(
array('controller/page', 'pattern'=>'page', 'urlSuffix'=>'', 'caseSensitive'=>false),
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
)
),
shailesh
(Shailesh Makwana990)
January 20, 2012, 9:52am
5
[color=#008800]Just Check Code[/color][color=#008800]
[/color][color=#008800]‘urlManager’[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] array [/color][color=#666600]([/color][color=#000000]
[/color][color=#008800]'urlFormat'[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] [/color][color=#008800]'path'[/color][color=#666600],[/color][color=#000000]
[/color][color=#008800]'caseSensitive'[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] [/color][color=#000088]true[/color][color=#666600],[/color][color=#000000]
[/color][color=#008800]'showScriptName'[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] [/color][color=#000088]false[/color][color=#666600],[/color][color=#000000]
[/color][color=#008800]'urlSuffix'[/color][color=#666600]=>[/color][color=#008800]'.html'[/color][color=#666600],[/color][color=#000000]
[/color][color=#008800]'useStrictParsing'[/color][color=#666600]=>[/color][color=#000088]true[/color][color=#666600],[/color][color=#000000]
[/color][color=#008800]'rules'[/color][color=#666600]=>[/color][color=#000000]array[/color][color=#666600]([/color][color=#000000]
array[/color][color=#666600]([/color][color=#008800]'controller/page'[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]'pattern'[/color][color=#666600]=>[/color][color=#008800]'page'[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]'urlSuffix'[/color][color=#666600]=>[/color][color=#008800]''[/color][color=#666600],[/color][color=#000000] [/color][color=#008800]'caseSensitive'[/color][color=#666600]=>[/color][color=#000088]false[/color][color=#666600]),[/color][color=#000000]
[/color][color=#008800]'<controller:\w+>/<action:\w+>'[/color][color=#000000] [/color][color=#666600]=>[/color][color=#000000] [/color][color=#008800]'<controller>/<action>'[/color][color=#666600],[/color][color=#000000]
[/color][color=#666600])[/color][color=#000000]
[/color][color=#666600]),[/color]
styleroom
(Styleroom)
January 20, 2012, 10:04am
6
to Ivica and shailesh
I have just tried your code - didn’t help…
I have got such server response =
Unable to resolve the request "".
The requested URL was not found on this server.
If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
The string = ‘useStrictParsing’=>true = has caused this server response
Splendid
(M Vanderhoop)
January 20, 2012, 11:07am
7
If you only have one controller, named site it this example, you could use:
'<action:[\w\-]+>.html' => 'site/<action>',
styleroom
(Styleroom)
January 20, 2012, 11:21am
8
I am sorry, guys… I am confused…
Here is my config file code =
return array(
'name'=>'Paul New Project',
'defaultController'=>'paul',
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'caseSensitive' =>true,
'showScriptName'=>false,
'urlSuffix'=>'.html',
//'useStrictParsing'=>true,
'rules'=>array(
'<action:[\w\-]+>.html' => 'site/<action>',
),
),
),
);
Where is my mistake?
Splendid
(M Vanderhoop)
January 20, 2012, 11:23am
9
styleroom:
I am sorry, guys… I am confused…
Here is my config file code =
return array(
'name'=>'Paul New Project',
'defaultController'=>'paul',
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'caseSensitive' =>true,
'showScriptName'=>false,
'urlSuffix'=>'.html',
//'useStrictParsing'=>true,
'rules'=>array(
'<action:[\w\-]+>.html' => 'site/<action>',
),
),
),
);
Where is my mistake?
Change:
'<action:[\w\-]+>.html' => 'site/<action>',
to:
'<action:[\w\-]+>.html' => 'paul/<action>',
Oh, and I haven’t defined a urlSuffix.
styleroom
(Styleroom)
January 20, 2012, 11:42am
10
to Splendid
Das ist fantastisch! = It’s excellent!
[color="#FF0000 "]Many times -> thanks a lot to you! [/color]
It work!
'<action:[\w\-]+>' => 'paul/<action>'
tell me please, Splendid: on the right - part of URL and on the left - pattern?
Am I right?
Splendid
(M Vanderhoop)
January 20, 2012, 11:52am
11
styleroom:
to Splendid
Das ist fantastisch! = It’s excellent!
[color="#FF0000 "]Many times -> thanks a lot to you! [/color]
It work!
'<action:[\w\-]+>' => 'paul/<action>'
tell me please, Splendid: on the right - part of URL and on the left - pattern?
Am I right?
I’m fairly new to Yii myself but this is how I see it. The left part is the url pattern, right side is the path of scripts. So the string before the slash is the controller, the part after the slash the view. With above code we switch those.
styleroom
(Styleroom)
January 20, 2012, 12:17pm
12
to Splendid
Once more - thank you very much!
I have added like this
‘<action:[\w\-]+>’=>‘page/about’,
and it works for me…