edkellett Posted March 26, 2009 Share Posted March 26, 2009 Hi, I would like to have a script that captures an extension after my domain URL and puts it in a variable which I can later use to redirect the page... For example... if someone types www.mydomain.com/johnsmith and there is no such folder as 'johnsmith', instead of displaying en error page, the script takes the string johnsmith and puts it in the variable $sample so I can match it off with a number of records in the database and then redirect, for example. I'm sure this exists somewhere so any help would be great... Cheeeeeeers in advance Ed Kellett Quote Link to comment https://forums.phpfreaks.com/topic/151265-url-redirect/ Share on other sites More sharing options...
Maq Posted March 26, 2009 Share Posted March 26, 2009 So what's your problem? Use scandir() to get the files in a directory. Use $_GET['var_name']; to get the persons name they put in the URL. Use header() to redirect. Quote Link to comment https://forums.phpfreaks.com/topic/151265-url-redirect/#findComment-794598 Share on other sites More sharing options...
edkellett Posted March 27, 2009 Author Share Posted March 27, 2009 Thanks for your reply... The thing is the actual file doesn't exist... A bit more info on what I am doing so that you might be able to help... I am building a directory of businesses... people sign up and have a listing on the site... so far so good... but I would like to be able to give them their own URL... like myspace do (myspace.com/samplename)... For example someone signs up and their name automatically generates a URL that they can put on their business cards etc...like www.directory.net/samplename Do you get me? So scanning for folders in the site won't do it because there won't actually be a folder... when they type in www.directory.net/samplename I need a way that php takes the string 'samplename' and scans the database to find an entry in there that matches... and if it finds a match redirects to that detail page... Thanks so much for your help... Ed Quote Link to comment https://forums.phpfreaks.com/topic/151265-url-redirect/#findComment-795071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.