Link to home
Create AccountLog in
Avatar of jpb123
jpb123

asked on

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.
Avatar of kebabs
kebabs
Flag of Australia image

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
ASKER CERTIFIED SOLUTION
Avatar of syrma
syrma

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer