Creating instant URL redirects using PHP without editing htaccess file

Hi. We're LearnOutLoud.com and we're looking to create instant URL redirects using our new tool TeachOutLoud (www.teachoutloud.com) which allows users to publish their own audio and video learning content. We want to create redirects for our authors to their author pages on the fly so if their name was Mark Twain there's a field in our system unto which they can type in their redirect to be www.learnoutloud.com/marktwain and this URL would redirect to their author page which is something like: http://www.learnoutloud.com/Resources/Authors-and-Narrators/Mark-Twain/225 (a rewritten PHP URL).

Currently we're creating these redirects manually through cPanel on the back end and it's a pain. And our programmers could do it through auto-editing the htaccess file but that is dangerous as if we corrupt that file the whole site goes down. So we'd like to come up with another solution for somehow creating these redirects. They can create ones that are built onto another level like a redirect off a php pages, but we want to make it so it's right off our URL www.learnoutloud.com/....

This is for marketing purposes for our teachers and authors and for ease of access to their pages. Like MySpace does it: www.myspace.com/tom. We can't figure out a safe way to do it, so we're looking for some one that has a solution.
jpb123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kebabsCommented:
You don't have a solution then...
You could use the "location" header to immediately process the "author page" on the server side like so:

<?php
header("Location: /Resources/Authors-and-Narrators/Mark-Twain/225");
?>

Just to let you know, editing .htaccess is not dangerous for an experienced developer. And anyone should immediately test the site after any modification to .htaccess and if the site did "break" they could roll back to the previous .htaccess file. I still recommend .htaccess
0
syrmaCommented:
This is what I have done in the past, please take a look if it can work for your situation.

The user is typing  www.learnoutloud.com/marktwain

There is no such real url, the user is send to the 404 error page.
You change this page with a php one, lets say not_found.php

in the not_found.php set something like this.
$author_name=substr('/', '', $_SERVER["REDIRECT_URL"];

$sql="SELECT url FROM authors WHERE author_name = '{$author_name}'";

if ($the_author_is_found, have the url){
 header("HTTP/1.0 200 OK");
 header("Location: ".$url);
}
else {
      header("HTTP/1.0 404 Not Found");
      //do something here, display error page message
}

so this worked for me, but you need to have some way to retrieve the url of the authors home page just knowing let's say "marktwain"
you might have url like this:  http://www.learnoutloud.com/Resources/Authors-and-Narrators/authors_home_pages?author_id=225
I don't know how you form this url  http://www.learnoutloud.com/Resources/Authors-and-Narrators/Mark-Twain/225
but if it follows some logic you should be able redirect to this url using the same logic.

hope this helps :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.