siwymilek
(Pmiloszewicz)
February 14, 2011, 11:32pm
1
Hello,
I have a problem with routing.
If I have controller called “group”, and in it is action “name”, my route it looks: “example.com/group/name/php-devotees/ ”. I’d to, my route was without action “name” in adress. (“example.com/group/php-devotees/ ”)
I tried to find a solution to my problem, but to no avail.
tri
(tri - Tommy Riboe)
February 14, 2011, 11:41pm
2
You should read about URL Management in the Definitive Guide to Yii.
/Tommy
siwymilek
(Pmiloszewicz)
February 14, 2011, 11:52pm
3
You helped me again.
I had problem, because in config, were put default rules, and so them routing didn’t work
thanks
edit:
I have a one more problem. When I put in adress “index.php” all it’s ok, but when I don’t put it, appear error:
It’s my .htaccess configuration:
RewriteEngine On
Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewrite all other URLs to index.php?r=URL
RewriteRule .* index.php?r=$0 [PT,L]
What’s going wrong?
APXu_KPblc
(Ivan Sobolev)
February 15, 2011, 8:13am
4
Have you set showScriptName to false?
gusnips
(Gustavo)
February 15, 2011, 12:19pm
6
My .htaccess is a bit different then yours
try it
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]
siwymilek
(Pmiloszewicz)
February 15, 2011, 1:04pm
7
It’s worse
redirect me to lower level (../)
gusnips
(Gustavo)
February 15, 2011, 2:15pm
8
Ok, now I’ve read the whole post
just do in your config something like :
'urlManager'=>array(
'showScriptName'=>false,
'urlFormat'=>'path',
'rules'=>array(
'group/<title:\w+>'=>'group/name',
),
),
and its done
gusnips
(Gustavo)
February 15, 2011, 8:04pm
10
use your old htaccess and
‘urlFormat’=>‘path’,
then try again
should work
siwymilek
(Pmiloszewicz)
February 15, 2011, 8:18pm
11
Of course, I tried to use my old .htacces, and it doesn’t work
siwymilek
(Pmiloszewicz)
February 15, 2011, 8:23pm
13
sorry I meant remove
'urlFormat'=>'path',
Still doesn’t work
edit:
I found solution.
First I gave in my .htaccess: (from docs)
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
Then in config:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'group/<title:\w+>/'=>'group/name',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
It does work!
Thanks everybody