PHP How To Create new Url for New Post


#1

I would like to know how to create a new url for each file upload. When people upload videos on the site, I would like the video to have its own url like this: “localhost/example.com/string”. For example, Youtube has a new url for each upload like this “https://www.youtube.com/watch?v=Dylkrgsloghntn” Is there a way for me to create a new url for each new post in php?


Create Dynamic URL PHP MYSQL
#2

You don’t, or rather, it is already there.
You hit a page that looks up the video to play, in your example:

https://www.youtube.com/watch?v=Dylkrgsloghntn

That is a get request with the key value pair v : Dylkrgsloghntn
So you are looking up, Dylkrgsloghntn on the page.


#3

So are saying that I would use the get method in the backend to produce the URL? Like in the example, “watch” is the srcript, and “Dylkrgsloghntn” is the string added to the URL?


#4

Not to produce it, it’s already there. You are just doing a lookup for the unique identifier that is passed with the url.


#5

So “Dylkrgsloghntn” is the file name, which is the url/file path?


#6

https://www.youtube.com/

^ URL

watch

^ file (using htaccess to remove the tech used for the file type) also know as a URI

?v

^ GET variable

=Dylkrgsloghntn

^ value of v. Unique identifier to look up the video from the database.


Create Dynamic URL PHP MYSQL
#7

Thanks. I understand it now


#8

I need some help creating a dynamic url for each file uploaded on the webpage. For example, I want something like this: https://example.com/php?id=1. I would like to know how I can create this from mysql and php.

Thanks


#9

I have already answered this question, recently.