How to hide the admin URL?

Hello everyone!

I want to hide the admin URL to users, so I set the following router

$router->add('my_admin_url/:controller/:action/:params', array(
    'namespace' => 'MY\Controllers\Admin',
    'controller' => 1,
    'action' => 2,
    'params' => 3,
));

And I can visit the backend properly by : http://localhost/mysite/my_admin_url/posts/list

But how to code in the *.volt of the backend viewer? for example, in the post viewer, {{ url("posts/list") }} will generate the HTML mysite/posts/list , BUT NOT my expect: mysite/my_admin_url/posts/list!

How to generate the url automaticly with some prefix (like my_admin_url)? or how to hide the admin url? Can I override the VOLT function url?



10.2k
edited Nov '15

Addtionally, the string my_admin_url is define in the /app/config/config.php

return new \Phalcon\Config(
    array(
    'database' => array(...);
    'application' => array(
        'controllerDir' => ...,
        'admin_url' => "my_admin_url"
    )   
));
edited Nov '15
{{ url("my_admin_url/posts/list") }}

dont work ?



10.2k

It can work, but how to change my_admin_url to other string ? the string is defined in the config file.

{{ url("my_admin_url/posts/list") }}

dont work ?

Just change my_admin_url to whatever you want in config ? OR you mean you want my_admin_url in url and use key in view ? Then i guess you have to inject config as a service and use it in volt.



10.2k

Thanks Jurigag. Could you please explain more exhaustive about how to do?

Just change my_admin_url to whatever you want in config ? OR you mean you want my_admin_url in url and use key in view ? Then i guess you have to inject config as a service and use it in volt.