SammyGh
(Ghazavi)
February 23, 2012, 4:51pm
1
Hi guys
I m trying to learn how to make url’s more readable. To start with I am going to change
http://localhost/user/index.php?r=user/create
to
http://localhost/user/create
and in config/main.php:
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array('user/index.php?r=user/create'=>'/create')
),
...................
I know it is not correct but how I can fix it?
Later I am going to fix the URL for all CRUD functions and Mange/List links
Thank you
Typed freehand, but it should work:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'create'=>'user/create',
),
),
SammyGh
(Ghazavi)
February 23, 2012, 6:38pm
3
Typed freehand, but it should work:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'create'=>'user/create',
),
),
Thank you but it gave me
http://localhost/user/index.php/create
I would rather to get me
http://localhost/user/create
Notice index.php is removed
Ah, sorry. i misunderstood what you really wanted Here we go:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
...
),
),
Don’t forget to set a .htaccess in place or you’ll end up in 404s.
SammyGh
(Ghazavi)
February 23, 2012, 6:44pm
5
I am afraid that i have no idea about that file !!
Hint: The Definite Guide to Yii is always a valuable source of information.
http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x
SammyGh
(Ghazavi)
February 23, 2012, 7:42pm
7
I am using XAMPP on Mac but I couldnt find .htaccess file. Any hint?
Thank you
If it isn’t there, you need to create it. Preferebly in your webroot.
SammyGh
(Ghazavi)
February 23, 2012, 7:57pm
9
Simple
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
did not actually do anything for me
SammyGh
(Ghazavi)
February 23, 2012, 9:51pm
10
I dont know why but I had the showScriptName inside the rules array. I just had to placed it before rules array and it works now
stasuss
(Stasuss)
February 24, 2012, 8:28am
11
Options +FollowSymLinks
IndexIgnore */*
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
i use this. works nice)
SammyGh
(Ghazavi)
March 9, 2012, 2:32pm
12
Worked for me too on Mac using XAMPP but I am trying to do the same thing on IIS on windows machines.
Any idea how clean url works on windows machine running IIS?
Not really. But it has to look similar to what is being described here.
SammyGh
(Ghazavi)
March 12, 2012, 8:23pm
14
I decided not work with IIS and rewrite rules. I installed XAMPP and using Apache but I really dont know why the same urlManager is not working.
I copied everything too XAMPP\htdocs.
What did I do wrong?
Thank you