Make custom URLs for files to hide their location - php

So I'm using the jQuery File Upload plugin to stream videos on my site. I'm just having a bit of problems.
So I've created a database that stores some of the details of the video that is uploaded, example: size, random and unique id, description, and some other things.
Now, I want to create a page for each video that is uploaded. I can easily do this through a .php file that just grabs the file location, and so on. However, how can I make it so that when users try to access a specific video they can type in something like this in the url
mysite.com/video/random_video_id
Then grab the random_video_id from the URL and use it in my PHP script to display necessary content on the page.
I just want to know how I can make custom urls like mysite.com/video/random_video_id that will trigger the php script that will generate the content of the page.

you need to use .htaccess for making the pretty url you want use...
if you make a url mysite.com/index.php?action=video&id=random_video_id ... I assume you know how you use $_GET and basic PHP, so I wouldn't go into the coding of the script which retrieves the videoes...
I use this site to make my .htaccess files - http://searchfriendlyurls.com/
And then you just write your domain in the first input (Domain Name) and in the second (ugly url) you write "index.php?action=&id=" and in the last (pretty url) you write "/"
Hope this helps you ...
And if you want to learn more about .htacces look here

Related

Is there a way I could redirect to a common php based pdf display template when a user clicks a link to a PDF file?

Is there a way I could redirect users to a pdf display template inside my website rather than going directly to the pdf file in their browser.
For example, if a user clicks on a link to http://example.com/docs/date/1.pdf
I want him to be redirected to let's say http://example.com/docview.php and this PHP needs to get details of the pdf file from the URL of the previous link and then display the right PHP file.
All help appreciated.
Thanks in advance!
Two options:
1 - Use htaccess Rewrite rules to turn PDF accesses into PHP. This has the advantage that the user will see a link that actually says "PDF" in the URL. However, it can get a bit tricky to implement and you need to be careful that it is limited or you could easily end up with ALL PDFs anywhere on the site, including some that should just be static PDF files, redirecting to the script. This will do exactly what you ask - Google htaccess Rewrite and you can get plenty of examples.
2 - Change the links to reference your PHP scripts directly. The PHP script can then provide whatever frame or viewer desired or simply check for permission (if needed) and read the PDF file and output it to the browser. A .php extension on the URL doesn't mattter - the browser will display PDFs correctly based on the mimetype of the output. This is my personal preference for providing PDF output and I have done this many times.

changing url name and what file it points to in php

I'm new to web development but i know some php basic stuff. Using ftp, i create directories then create simple php scripts there, simple as echoing a string. Which can be accessed like,
www.sampledomain.com/folder1/subfolder2/hello.php
After some time, my friend introduced me to wordpress which is what they described as CMS. I tried to visit her site www.majaflores.com then i click on some stuff there and i noticed the url changed to http://majaflores.com/project/if-i-let-you-in-please-dont-break-anything/
At first, its pretty normal for me because its just a link where there is a folder named "project" and inside it another folder named "if-i-let-you-in-please-dont-break-anything". But when she showed me the ftp folders directory, i didnt see any folder named "project" under main folder of the domain. How did wordpress manage to do this? and how can i implement this manually?
Just wanted to say that like most server-side code environments, PHP also let you parse URLs "manually" and decide what to do accordingly, be it return a file or generate some content.
You can find more information about how PHP is parsing URLs in here:
http://php.net/manual/en/function.parse-url.php
and some discussion regarding it in here:
URL handling – PHP vs Apache Rewrite
This is they way WordPress stores data. U can further see the setting under Permalink.
Under Permalink, u can have options to render ulr as page id, category names and more. You can also use your own format over there.
Just a note, WordPress stored data in database not as a content on FTP directory.

Having Post Name in the url without rewriting current url structure

Is it possible to have something like this in wordpress:
http://example.com/post/2135/post-name
without having to rewrite my current url structure which is
http://example.com/post/2135
I want to keep it, and be able to access posts both ways. With and without the post-name
is it possible to have it that way? maybe make wordpress ignore that there's the post name attached at the end?
i believe it is in the php.ini file
example,
me.com/boss
file structure
root/boss/index.php
the index.php file will auto load.
but if you are used MVC you can change the results of what is displayed.
but
can you use http://example.com.post/2135/index.php&postname=lol

How to exclude a wp page and rewrite in htaccess?

I have a wordpress site with a page named domain.com/dogs. I want to change that exact page to a regular blank white page that I can type text or html in and be able to turn this feature on and off easy enough manually.
What will the name of the file be that I'm replacing it with? domain.com/dogs or domain.com/dogs.php etc? Remember I want it to be EXACTLY the same url.
Thank you so much!
You have to actually find the file that you're talking about on the server or
use GoogleChrome: Right-click(on page)>inspect element > Network (tab).... where you will find the file. The file name and extension will be shown.
Once you know the page extensions you will know what to put:
domain.com/
NOTE: This will work unless there is a masking script that rewrites the url of address bar.
Then you have to go into the server and edit the file itself, and delete all of the contents of the page. Then you can start a new page with the standard HTML headers and include the text you want. NOTE: MAKE SURE THAT YOU SAVE THE FILE WITH THE SAME NAME AND EXTENSION TO THE SAME LOCATION, this will do what I think you're trying to achieve.
I hope it helps.

Custom URL rewrite, migrate one CMS to Wordpress

I am trying to move my image gallery site from one CMS to Wordpress.
On current CMS I have page with medium size image on it with URL:
www.my-example-site.com/folder-one/subfolder-one/example-image-name.jpg.html
and another page with full resolution of same image on it with URL like this:
www.my-example-site.com/full-image/folder-one/subfolder-one/example-image-name.jpg-some-custom-keywords.html
I managed to make same address on test WP for medium size image, I created same categories with, and used same URL slug for categories.
After that, under settings --> permalinks I made custom URL structure like:
www.my-example-site.com/%category%/%postname%.jpg.html
and that made me the same urls for page with medium size image on it.
But, problem is with page with full size image on it.
Is there any way (some rewrite rule or something) to get another page to. It could be 301 redirect to something like this:
www.my-example-site.com/folder-one/subfolder-one/example-image-name.jpg.html?-some-custom-keywords.html
or anything similar, just to be able to use data as like on stardard page.
than I can use custom url check (on very top of single.php) to see if page contains "?-some-custom-keywords.html" to include file for generating that new page,
if there is no that variable to include file for generating standard post page.
Please note that there are multiple different combination for "-custom-keywords.html" suffix (about 15)
If you have any question or suggestion please ask.
Regards.
I'm guessing that these URL paths are stored in the database of your old CMS.
If so, you should be changing them there to match the standard URI of WordPress instead of rigging a way for the old paths to work.

Categories