Page 1 of 1
The best way to redirect?
Posted: Mon Dec 29, 2003 1:50 am
by fastfingertips
I want to redirect someone to another page, can you give me a code example on how to do that?
Posted: Mon Dec 29, 2003 2:33 am
by Weirdan
[php_man]header[/php_man]
It should be called before any output...
Posted: Mon Dec 29, 2003 5:53 am
by devork
you can also use HTML features to redirect user from one page to another
Code: Select all
<meta http-equiv="refresh" content="1;url=your_url">
-you can also adjust seconds to redirect the user
this example you can see on this forum when you post a reply it stays 3 second after posting, saying "your message has been posted...." and then redirects you to original thread from where you came
Posted: Mon Dec 29, 2003 6:38 am
by m3mn0n
Not to mention JavaScript
<SCRIPT LANGUAGE="JavaScript">
<!-- Change location to suit your needs below
window.location="
http://www.yourdomain.com/";
// -->
</script>
Posted: Tue Dec 30, 2003 4:53 am
by devork
^ what if javascript is disabled in browser
-i think if redirection is not done by browser, then user should be given a link to the directed page.
what about when...
Posted: Wed Jan 14, 2004 3:21 pm
by tdelobe
I have a case where I need to have a whole bunch of "user-friendly" urls that each redirect to a different no user-friendly url on my site. for example....
www.mysite.com/contact redirects to
www.mysite.com/index.php?page=home.contact
That way people can send out easy urls in emails or print docs where someone needs to type a url in.
So basically, I would like to put some code at the top of my controller template that sniffs out the url a user types in and if it is one of the ones I designate (like say the one above) than it redirects to the appropriate page.
Anyone know the best way to accomplish this task?[/b]
Posted: Wed Jan 14, 2004 3:26 pm
by Unipus
Aha. You want mod_rewrite on your server (assuming you're using Apache as your server).
You might find this article has some helpful information:
http://www.alistapart.com/articles/succeed/
And here's a URL rewriting guide that's helpful:
http://www.engelschall.com/pw/apache/rewriteguide/
sorry....
Posted: Wed Jan 14, 2004 3:31 pm
by tdelobe
....sorry, didnt provide enough info on my situation. i am usings php 4 on windows IIS. so the apache thing in not an option. any other ideas?
isapi rewrite
Posted: Wed Jan 14, 2004 3:41 pm
by tdelobe
ok, so i found this for IIS.
http://www.isapirewrite.com/
however, is there anyway to this this with php or javascript?
Posted: Wed Jan 14, 2004 6:53 pm
by Unipus
The ALA link I posted has some information that might get your brain turning. Most of the work in their example is done in PHP. But yeah, it can mostly be done by PHP... search for PHP URL rewriting or somesuch.