How to create a customized URL/page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
David_deb
Forum Newbie
Posts: 3
Joined: Wed Oct 01, 2014 4:57 pm

How to create a customized URL/page

Post by David_deb »

Hello,

What I'd like is to be able to send a person to a unique page via a customized link including it's name and displaying it on the page.

So, to be clear, I have a page at this URL:
mysite.com/video/

I send an email to the person, let's say his name is Joe so I just add Joe to the URL:
mysite.com/video/joe
He is then sent to the page and can see somewhere on the page his name, like "Hello Joe, watch the video I did for you...".

If his name is Jane then the URL would be:
mysite.com/video/jane

I just want to have one page and that whatever I add to the URL it would drive the person to the URL mysite.com/video/
This is to avoid to have to create an identical page X times, one for Joe, one for Jane, one for David...

It certainly is easy but as I'm just a beginner in PHP, it's not so obvious for me.

Thanks a lot for your help.

David
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to create a customized URL/page

Post by Celauran »

You basically want a rewrite rule in your .htaccess file (assuming you're using Apache). This should do the trick:

Code: Select all

RewriteEngine On
RewriteRule ^video/(.*)/? video/?q=$1 [NC,L]
David_deb
Forum Newbie
Posts: 3
Joined: Wed Oct 01, 2014 4:57 pm

Re: How to create a customized URL/page

Post by David_deb »

Celauran wrote:You basically want a rewrite rule in your .htaccess file (assuming you're using Apache). This should do the trick:

Code: Select all

RewriteEngine On
RewriteRule ^video/(.*)/? video/?q=$1 [NC,L]
Thanks for this code. But I never used any command to change the .htaccess file except for scripts I purchased and then just copy/paste some piece of code in the file.

q=$1 is a variable I could use in my script on the .php page? It would contain the text entered in the URL after the mysite.com/video/?

Thank you very much for your help.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to create a customized URL/page

Post by Celauran »

It was just an example. q can be anything you want. If would be available to the script through $_GET['q'] (or whatever you call q)
Jaz Madrid
Forum Newbie
Posts: 1
Joined: Mon Sep 15, 2014 5:44 am

Re: How to create a customized URL/page

Post by Jaz Madrid »

Thanks, I had the same quiestion
David_deb
Forum Newbie
Posts: 3
Joined: Wed Oct 01, 2014 4:57 pm

Re: How to create a customized URL/page

Post by David_deb »

Thank you very much Celauran.
Post Reply