Jump to content

How do the URL's work, do they use PHP?


pappakaka

Recommended Posts

I'm sorry if this maybe is an obvious understanding for you, but i can't understand one thing with URL's.

 

If i create my page called "index.php" and put it in a folder called "folder" then the URL in the address bar would be: http://www.website.com/folder/index.php

 

But then i deside to add a few more pages with like next and previous links to scroll through them. I put those pages in a folder called "pages" within the folder "folder". Now the URL's would something look like this!

 

http://www.website.com/folder/pages/page1.php

http://www.website.com/folder/pages/page2.php

etc...

 

Thats the only way i know URL's are created and look like. But now too my question..

 

This is a few URL's i've seen on a site and every URL leeds to a new page but there is no slashes indicating new folders? How do you do that? Here is some examples of how the URL's could look like:

 

http://www.website.com/index.php

http://www.website.com/index.php?p=new

http://www.website.com/index.php?p=new&page=121

http://www.website.com/merge.php

http://www.website.com/merge.php?id=20381

 

And every URL was a comnpletly new page?  :shrug:

 

Link to comment
https://forums.phpfreaks.com/topic/227625-how-do-the-urls-work-do-they-use-php/
Share on other sites

It's

-http://www.website.com/folder/index.php <- your main page for the folder (if you have one)

-http://www.website.com/folder/page1.php

-http://www.website.com/folder/page2.php and so on

 

You (or at least I do) build these types with a get statement and guery

-http://www.website.com/index.php?p=1

-http://www.website.com/index.php?p=2

 

PS as cyberrobot said, pages like -http://www.website.com/index.php?p=1 pull info from the database

 

This is the basics of dynamic content. Generally, you pass data through the url, this data is used within the page then to identify some content (generally stored in a database) and display it.

 

A simple example.

 

<?php

if (isset($_GET['id'])) {
  $id = $_GET['id'];
} else {
  $id = 1;
}

echo "This is page number $id<br />";
echo "Click <a href='?id=" . $id+1 . ">here</a> to see page number " . $id+1;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.