Magento – How to define if url exists at Magento

overridesurl

For example I have set of urls, their rewrites, etc:

test1.html
catalog/product.html
thank-you
catalog/product/view/id/34

All this URLs gives 200 OK at response. My aim is to filter incoming URLs and don't allow URLs that do not exists inside Magento (404 response I think).

How can I define that this URL will give 200 OK inside of Magento?

Best Answer

I think the safest way to find out if an URL will give you 200 or 404 (or any other header) is to make a call to that URL. Other than that I don't see a safe way. URLs can be valid (catalog/product/view/id/34) but still give you 404 because the product is disabled or is not visible in that store view. Same goes for CMS pages URLs (test1.html), not to mention that test1.html might be the URL for a custom entity (not a CMS page).

Related Topic