FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Auto redirect your visitors to a different page





namneu
To auto redirect your visitors to a different page, copy and paste this Meta Tag in between your <HEAD> and </HEAD> tags :

<meta http-equiv="refresh" content="2; url=http://www.yourdomain.com/page2.html">

( You can change content="x", with x is the redirect delay in seconds )
Simple !
mathiaus
PHP
or if your using php and have no html shown and would rather not type more having to add head and html tags just use the below. This must be used before any output is shown
Code:
header('Location: http://www.example.com/');



Javascript
Code:
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
window.location="http://www.yourdomain.com/";
// -->
</script>
mirzapirza
If you're using a client-side redirect (javascript, meta-tag) you should give it a few seconds before it redirects, just so you don't break the user's back-button.

Imagine this: I enter your site from google. You redirect me to page2. I decide I don't like it and want to go back to google. I press back, and you redirect me again before I have the chance to press back again to go to google.

Be good boys and girls and either avoid client-side redirects or give your user's a few seconds.
Bookface
To avoid the problem mirzapirza discussed, if you have access to the server configuration you can forward pages by sending a 301 or 302 Page Moved redirect.

This page discusses when to use these, and how:
http://www.404-error-page.com/301-apache-httpd.conf-redirect.shtml
snowboardalliance
Bookface wrote:
To avoid the problem mirzapirza discussed, if you have access to the server configuration you can forward pages by sending a 301 or 302 Page Moved redirect.

This page discusses when to use these, and how:
http://www.404-error-page.com/301-apache-httpd.conf-redirect.shtml


Looks interesting, where do you put the code though?
Bookface
Sorry, I thought that page's instructions were a little more detailed.

You can modify most Apache configurations, if the general config file for the server allows it, by putting directives in an plaintext file called .htaccess (note, that's [period]htaccess.) This page explains the redirect process

http://www.javascriptkit.com/howto/htaccess7.shtml

and goes into more detail about how to set up the .htaccess file an the first page of the series, as well as showing off some of the other things that can be controlled by an htaccess file, such as custom 404 error pages, custom directory listings, and so on.

If you have full access to the config files for the server, you can make these modifications in the Apache config file httpd.conf and also change whether custom .htaccess files will be processed.

No idea whether FriHOST supports this or not, as I haven't signed up for an account yet. But I'll let you know soon. Smile
ddlforum
Thanks people, i've been needing this to direct my homepage to /forums so now whenever a user comes on its no more clicking a link its auto, thanks for the information Smile
Bookface
Bookface wrote:
No idea whether FriHOST supports this or not, as I haven't signed up for an account yet. But I'll let you know soon. Smile


Strike that, "- .htaccess" is clearly listed as a feature here:

http://www.clickherefree.com/hosting-free/details.php?id=2544

P.S. Go vote there if you like FriHost because I wouldn't have found you guys without them.
snowboardalliance
You don't need htacess for 404s, Cpanel does it automatically.
Daniel15
Quote:

You don't need htacess for 404s, Cpanel does it automatically.

I believe that cPanel just sets the configuration in the .htaccess file for you

And just a note about 301 vs. 302 redirects...

A 302 redirect is meant to be used as a TEMPORARY redirect (ie. not permanently). By default, if you use a header() call to redirect, it will be a 302:

Code:

header("Location: http://www.example.com/");


A 301 redirect is a PERMENANT redirect. Search engines will not index the redirector page, but rather the destination (as opposed to a 301 redirect, where the search engine will still list the original URL). To send a 301 redirect, you will need to use 2 header() calls, as shown below:

Code:

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");


Hope this helped someone Smile
Related topics
Adding Music or Sound to Your WebsitE
resolution detection with javascript
auto Video File playing Page making script
234 productions
php page-refresh/redirect/boot help needed please
Login System help
Rather strange pagerank thing (not really a problem)
Auto redirect.
ADBRITE
General .htaccess tutorial.
Redirect to previous page on login
The one biggest thing that would be good to put right
is that possible to redirect a pr page of a domain
Can you improve my sql injection detection
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.