You can use Global variable Action. Salesforce will generate URL for you. You don't have to do Anything.. This button will redirect to Account Edit page..
You just need to pass record Id
<apex:commandButton value="EDIT" action="{!URLFOR($Action.Account.Edit, Account.Id)}" />
Another option you could use this
<apex:outputLink value="{!LEFT($CurrentPage.URL,FIND('/',$CurrentPage.URL,9))+relatedto.Id+'/e?retURL=%2F'+o.Id}">Edit</apex:outputLink>