Jump to content

URL resolving


mrjasongorman
 Share

Recommended Posts

I'm intrigued about how Processwire resolves URLS. I've been having a snoop around the database and found that each page has a "name" which looks to be it's section of a URL.

The thing that's puzzling me is say a page is at this address example.com/mens/tshirts/product-name/  how does processwire process that URL? i understand it's easy enough to process just example.com/product-name/ that's just a simple database lookup, but how does it go about validating the position of that page in the database hierarchy with the hierarchy of the URL?

I know that the web server is rewriting urls to /index.php?it=$uri&$args

I noticed that Wordpress and other systems must use a similar technique.

But how does Processwire manage to do this at such speed? ???

Any help on how this works would be great :)

Link to comment
Share on other sites

There's the page_parents table in the db, which holds all the hierarchy related information. And the actual db query is just more or less a simple $pages->get("path=/mens/tshirts/…/");, which you can find in ProcessPageView::getPage(). If the first try won't find anything it just checks each hierarchy above if pages are found and if so, the other parts of the url are further evalulated as urlSegements.

The actual domain is only checked against the $config->httpHosts whitelist and not really involved in the page finding process.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...