Mr Rich UK Posted July 15, 2009 Share Posted July 15, 2009 Hi, One thing I have been trying to work out recently is how to redirect someone to part of my site. Basically what it is, is when I had the previous version of my site, if you wanted to look at someone's particular work you would go to http://www.examplesite.com/richard Because there was a file there called richard.php it obviously brought up his work. Now I have recreated the site so that it is fully dynamic, when you want to see Richard's work you have to go to: http://www.examplesite.com/director.php?director_id=2&shortname=RICHARD&fullname=RICHARD%20PULLAR&linkname=richard So, what I want to try and find out if this is possible (and I have looked a lot now) is if someone goes to http://www.examplesite.com/artistname it will take them to the correct person. Now, there is one way of doing this, which is creating files named richard.php etc and then putting in a redirection script in each, which obviously defeats the object because I may as well actually make a page each for them and not have the site as dynamic. Is it possible to write one file to my server that can somehow use the URL the person has typed in to know which page to go to? That if that directory/page doesn't exist it knows and uses the Database to know where to direct the person to? If people put in lowercase, for example http://www.examplesite.com/richard in the directors table in the database there is a field linked to the ID called 'linkname' which has stored in it richard in lowercase. Any help in this matter would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/166038-redirection/ Share on other sites More sharing options...
trq Posted July 15, 2009 Share Posted July 15, 2009 The file you need to redirect too is already there by the looks (director.php), you just need to use mod_rewrite (nothing to do with php) to rewrite nice url's like http://www.examplesite.com/artistname to the actual url like http://www.examplesite.com/director.php?director_id=2&shortname=RICHARD&fullname=RICHARD%20PULLAR&linkname=richard Searching mod_rewrite examples should find you plenty of information on the subject. Link to comment https://forums.phpfreaks.com/topic/166038-redirection/#findComment-875648 Share on other sites More sharing options...
Mr Rich UK Posted July 15, 2009 Author Share Posted July 15, 2009 I will look up mod_rewrites and see how I do. The file director.php is basically a biography page for a director, which then gets its info from the database based on the director_id from the link clicked. What I'm saying is at the moment with my new site, if you go to examplesite.com/richard there is nothing there because there is no file called richard.php and there is no director called that. So if you were to go to examplesite.com/richard I would want it to re-direct to director.php but with the correct director_id, shortname, linkname and fullname. Link to comment https://forums.phpfreaks.com/topic/166038-redirection/#findComment-875650 Share on other sites More sharing options...
trq Posted July 15, 2009 Share Posted July 15, 2009 I know what your saying, and that is exactly what mod_rewrite can do. Link to comment https://forums.phpfreaks.com/topic/166038-redirection/#findComment-875662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.