简体   繁体   中英

url rewrite not working in cakephp

I am working in cakephp.i have done rewrite url for all forms and links. and i have done server side validation through model. but when server side error is generate then url rewrite not working

one form i have done urlrewrite for that like

Router::connect('/employers/edit-securitydetail/:id', array(
    'controller' => 'fj_employers',
    'action'     => 'editSecurityDetail',
    'id'         => '[0-9]+'
));

then i can access this controller using this url employers/edit-securitydetail/1

when server side error is generate then url change to fj_employers/editSecurityDetail/1

can anyone help me

Use below:

Router::connect('/fj_employers/editSecurityDetail/:id', array(
    'controller' => 'fj_employers',
    'action'     => 'editSecurityDetail'),
    array('id' => '[0-9]*')
);

This will fix the problem. Actually the problem is in url rewriting correctly.

Try putting a second route in that looks like this:

Router::connect('/employers/editSecurityDetail/:id', array(
    'controller' => 'fj_employers',
    'action'     => 'editSecurityDetail',
    'id'         => '[0-9]+'
));

or maybe this:

Router::connect('/fj_employers/editSecurityDetail/:id', array(
    'controller' => 'fj_employers',
    'action'     => 'editSecurityDetail',
    'id'         => '[0-9]+'
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM