• Now, I know that the posts are located in the MySQL database. That’s not my question. My question is that I’ve leared that when I type https://www.example.com/something.html it will take me to a file called “something.html” in the root directory of the server where example.com is hosted.

    But… I just made a post in my WordPress blog. The URL to that post is “www.example.com/a-test-post”. But I can’t find a file called “a-test-post” in my web hotel.

    Of what I’ve learned about this, when there is no file called “a-test-post” I should get a 404 error when I type in the adress.

    So, what I am wondering is; how does this work? Why don’t I get a 404 error when there is no file called that on my server? I am asking to learn. Hoping for some WP geniuses to answer.

Viewing 12 replies - 1 through 12 (of 12 total)
  • But I can’t find a file called “a-test-post” in my web hotel.

    That’s because there isn’t one. The data is pulled from your database & the page generated on demand.

    Thread Starter havardhedde

    (@havardhedde)

    Alright. But how is this done? When my browser comes to example.com/a-test-post it queries the server for a file called just that, but then the server says back that there is no such file, and sends the browser to another file instead (i suppose that’s the way it goes). But which mechanism is responsible for this?

    What exactly redirects the browser to the correct file?

    Thread Starter havardhedde

    (@havardhedde)

    Is it the browsers interacion with the content of the CGI bin folder which tells the browser to look up the page when the page does not exist? Or does the CGI have nothing to do with this?

    cgi has nothing to do with it. Your browser queries the server for a file called example.com/a-test-page/ WordPress responds by creating that file and sending it to your browser. The file is not saved anywhere on your server.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    WordPress responds by virtually creating that file. It’s magic.

    When you go to domain.com/a-test-page, your .htaccess file sends that to index.php. The index.php has some insanely complicated code that takes ‘a-test-page’ and looks in the database for the post with that slug, then it generates the content on the fly. Dynamic webpages. Livin’ in the future ??

    Thread Starter havardhedde

    (@havardhedde)

    Alright. Thanks both of you. So .htaccess -> index.php -> making the site :-). Got it!

    So, I am guessing when the broswer “doesn’t find” a-test-page to begin with, the browser then automatically know that it should query .htaccess.

    Not quite. The server intercepts all calls from browsers and passes through the .htaccess rewrite rules first.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    The browser only says “Hi, I want a-test-page” and then waits for the server to do the work ??

    Of course, that’s not how any of my WordPress sites work, but I’ll let it slide for the sake of clarity of simplicity ??

    Thread Starter havardhedde

    (@havardhedde)

    Graq, please do elaborate. I don’t want the simple version. I want the real deal.

    I think Graq’s comment was meant as a joke…

    I think Graq’s comment was meant as a joke…

    Not entirely. I don’t use Apache to serve any WordPress sites, so I don’t make use of .htaccess files (as they are Apache specific).

    However, havardhedde is unlikely to not use Apache now or the near future, and it makes no difference to the answer to the original question. The MySQL PHP stack is implicit.

    Ignore my frippery, and instead learn more about how the internet works: https://www.howstuffworks.com/web-server.htm

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How does WordPress send you to a post, when it's not on the server?’ is closed to new replies.