I am trying to use the ‘path’ option for urlManager, so my sites URLs can be a littler easier to read, e.g. www.domain.com/user/profile.
I’ve set the urlFormat value of urlManager to ‘path’, which worked perfectly but still left the index.php in the URL, e.g. www.domain.com/index.php/user/profile.
I did a bit of research and found the showScriptName option for urlManager, so I set this to false in order to get rid of the index.php from the URL, but now I can only get to the index page and all the links take me to a 404 error page. Any suggestions as to why this might happen?
I’ve tried taking out the custom rule I popped in there (’/<category:\w+>/<county:\w+>/<city:\w+>/<id:\d+>’=>‘user/view’,), but still none of the links work and I just get a 404 error.
Ok, someone had removed the default .htaccess file and replaced it with a custom one, which I think was half the problem. I’ve reset the .htaccess file to:
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
Now I get the custom Yii 404 error (rather than the servers one, which I was getting before) when I navigate to a controller AND action i.e. www.domain.com/user/view will result in a Yii 404 error being thrown, but www.domain.com/user will display the actionIndex method in the User controller fine.
Very odd, any suggestions would be greatly appreciated!
In general, the rules for the urlManager should appear in the order of "specific patterns to general ones". Otherwise the rules with specific patterns will have their candidates eaten up by the general ones.
Thanks Softark that did make a difference, all seems to be sorted now! Just a few more complicated rules to work out! fingers crossed!
Lubosdz, thanks that’s how I was doing it, I meant if I went to www.domain.com/user/view it would run the actionView in the UserController fine, but after applying the urlManager, it stopped working and displayed a 404 error. However, navigating to www.domain.com/user/ would work fine and display the actionIndex of the UserController. Which was very odd!