Added logic for api and added in .htaccess