Yii Framework Forum

UrlManager rule doesn't work in new server

(Nicola) #1

i’ve a site working in local and remote server. I’m migrating it on a new server and works.
The only thing i can’t get are (standard) rules for pretty url. These rules works perfectly in development and production, but fails in the new server.


The error i get is in every detail view (actionView, url like /index.php/controllerName/18652), regardless of the controller used. System say:
System couldn't find the required "18652" action
Seems it miss the action and get the id as action

Also the update actions (url like /index.php/controllerName/update/18652) returns a “400 error”

Any suggestion?
Thanks in advance,

(Alirz23) #2

check your url rewrite rules for web server


(Nicola) #3

Thank you alirz23 but .htaccess works and rewriterule is on.
That should only be needed to suppress the index.php part of the url, isn’t it?
I suppose that the server or Yii is not able to catch the id part of the url rule…but… why???

(Alirz23) #4

I also believe it has to do something with index.php can you manually remove it and try if that works, can you also make the following changes in your urlManager config

'urlManager'=> array(
    'enablePrettyUrl' => true,
    'showScriptName' => false,

(Nicola) #5
//                                    '<controller:\w+>/<id:\d+>'=>'<controller>/view',
//                                    '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
//                                    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 

Without rules it works, with or without index.php in the url (with modification to htaccess to remove the index.php part)

With rules, doesn’t work!


(Alirz23) #6

I think it could be related to urlFormat try removing that with settings I posted above

(Nicola) #7

enablePrettyUrl is a yii2 property :frowning: