Redirecting based on request


#1

Does anyone know if it is possible to redirect to a specific location based on a requested http. For example:

User goes to:
http://www.domainName.com/someDir

Which then will foward them to:
http://www.domainName.com/someOtherDir/index.php based off of the requested http string.

I do not want to actualy set up the directories, cause I intend to have multiple instances of this, so having to set up a directory and add an index.php page to use a Location:gohere type set up I am not wanting to do.

I know in Apache, you can set up redirects without actualy creating a dir. That is sort of what I am looking for, to build a class to contain all server requests, including bad ones.


#2

Well it’ early in the morning and my first thought to this is that if you are running on a *nix platform, then you can just do an link to the directory.

Since “someOtherDir” must already exist, you could just create a symbolic link and be done with it.

i.e.

ln -s /home/user/public_html/someOtherDir /var/www/html/someDir

That way there is no need to redirect. It will just launch directly to where you need to go.

Alternatively I suppose you could pass a single parameter and use that in a redirect script.

http://www.domainName.com/redirect.php?location=someDir 

Where the someDir would be redirected based on the conditions you specify.

Just my thoughts. Don’t know if it will work for what you want to do or not.


#3

I appreciate your reply.

On Linux, that would be ran through the command line? If so, do you happen to know if PHP can run a command like that?


#4

You could use shell_exec http://us2.php.net/shell_exec