The best way to redirect?
Moderator: General Moderators
-
fastfingertips
- Forum Contributor
- Posts: 242
- Joined: Sun Dec 28, 2003 1:40 am
- Contact:
The best way to redirect?
I want to redirect someone to another page, can you give me a code example on how to do that?
Code: Select all
header('Location: somepage.php');It should be called before any output...
- devork
- Forum Contributor
- Posts: 213
- Joined: Fri Aug 08, 2003 6:44 am
- Location: p(h) developer's network
you can also use HTML features to redirect user from one page to another
-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
Code: Select all
<meta http-equiv="refresh" content="1;url=your_url">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
Not to mention JavaScript
<SCRIPT LANGUAGE="JavaScript">
<!-- Change location to suit your needs below
window.location="http://www.yourdomain.com/";
// -->
</script>
what about when...
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]
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]
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/
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/
isapi rewrite
ok, so i found this for IIS.
http://www.isapirewrite.com/
however, is there anyway to this this with php or javascript?
http://www.isapirewrite.com/
however, is there anyway to this this with php or javascript?