first you can get url then in java with selenium you can below condition in if:
(String)((JavascriptExecutor) driver).executeScript("return document.contentType;").equals("text/html");