PHP How To Create new Url for New Post

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?

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.

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?

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

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

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.

Thanks. I understand it now

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

I have already answered this question, recently.

Sponsor our Newsletter | Privacy Policy | Terms of Service