Redirecting based on request

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

User goes to:

Which then will foward them to: 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.

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.


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. 

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.

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?

You could use shell_exec

Sponsor our Newsletter | Privacy Policy | Terms of Service