English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

...here's the problem.

My website works with the following URLs:

www.bill.tk/page.php ?content=links
www.bill.tk/page.php ?content=auctions
www.bill.tk/page.php ?content=contact

and so on.

Is there a way of automatically redirecting

www.bill.tk/whatever

to

www.bill.tk/page.php ?content=whatever


The only way I can think of doing it is a custom 404 page that realises that www.bill.tk/something doesn't exist, work out that URL, and put "page.php?content=" in after the forward-slash, and carry out the redirection.

I have no idea how to do this though...

Any ideas?

2007-05-18 12:42:10 · 3 answers · asked by Bill 3 in Computers & Internet Programming & Design

3 answers

you can do this using mod_rewrite of Apache through .htaccess file.
but your host must support mod_rewrite

you can get more info from the sources listed

2007-05-18 12:56:22 · answer #1 · answered by Total IT Solution 3 · 2 0

In addition to using mod-rewrite, which is the proper way to do what you want, you can cheat by creating a directory and placing a PHP page as its index page, and have that page simply redirect the user to the right place.

For example, if you want www.bill.tk/whatever to redirect to www.bill.tk/page.php ?content=whatever, then your index page in the /whatever directory would be:

header('HTTP/1.1 200 OK');
header('Location: /page.php ?content=whatever');
?>

Of course, this won't maintain the directory structure of the URL as being www.bill.tk/whatever -- the URL will change to page.php ?content=whatever

And again, the right way to do it is with a rewrite

2007-05-19 00:25:31 · answer #2 · answered by Anonymous · 0 0

www.bill.tk/whatever takes your visitor to the /whatever directory. All you need is for the default page in that directory to be either the desired PHP page or a redirect to page.php using the desired parameters.

2007-05-18 21:47:19 · answer #3 · answered by injanier 7 · 0 1

fedest.com, questions and answers