Removing duplicate code and showing domainname only in url