How to edit a url with JS?


In the JS that I am developing, I must enter and / or use a url dinámica in case the project name changes ...

For this reason, try using the following:


which shows me the following /proyecto/index.php/usuario/

How could I modify this (window.location.pathname) in such a way that it does not show me the name of the controller that in this case is usuario if not only this? /project/index.php /

I would appreciate immensely if you can help me with this.

asked by JDavid 06.04.2017 в 15:18

2 answers


If you intend to do it with Javascript, try history.pushState , with this you can change the addresses.

According to Mozilla , how you should do it is:

<script type="text/javascript>
    var stateObj = { estado: "ok" };
    history.pushState(stateObj, "página 2", "dirección.html");

This will cause the browser to display the address http://midominio/dirección.html but without redirecting or checking if dirección.html exists.

answered by 06.04.2017 в 15:26

answered by 07.04.2017 в 04:40