PDA

View Full Version : [TUTORIAL] How to redirect a webpage - the clever way.



Florx
31-05-2007, 12:26 PM
The best way to redirect a page is to use something called a "301 Redirect". What this 301 does is redirects to a different page. What makes 301 redirect the best, is that not only does it redirect, it does it safely and search engine friendly too!

HTML Redirection

How do you redirect using HTML? Here is how: DON'T!!!

The result of using META refresh is that when you use it the page WILL be de-indexed from every search engine.

NOTE: This also applies to javascript redirection. Search engines can easily detect javascript and meta tag redirection, so just dont do it, use the 301 redirect.

301 Redirect Using htaccess

Using htaccess to do the 301 redirect is highly suggested due it being easy to manager rather than setting redirects on each page.

Here is how to do it:
Create a file on the root directory of your website called .htaccess (this probably won't work on free hosts)
Open the .htaccess using notepad (or whatever text editor you like)
Add this to the file
Redirect 301 /old/old.html http://www.you.com/new.htmland edit that to fit how you need it.

To redirect the main page of your site to a new directory (e.g. www.habboxforum.com/site (http://www.habboxforum.com/site))


Redirect 301 / http://www.habboxforum.com/site/index.html301 Redirect using Mod_Rewrite

Mod_rewrite is extremely usefull for changing your site from http://www.habboxforum.com to http://habboxforum.com or vice versa. To do this create a .htaccess file and open it ready for editing:


RewriteEngine On
rewritecond %{http_host} ^habboxforum.com


rewriteRule ^(.*) http://www.habboxforum.com/$1 [R=301,L]

^ That will go to http://www.habboxforum.com

\/ This will go to http://habboxforum.com


RewriteEngine On
rewritecond %{http_host} ^habboxforum.com


rewriteRule ^(.*) http://habboxforum.com/$1 [R=301,L]

How does it work?

So come on Jake how does that actually work?

RewriteEngine On // That turns on the engine so it will work :)
rewritecond %{http_host} ^habboxforum.com // That asks the browser if your address is any file under habboxforum.com
rewriteRule ^(.*) http://habboxforum.com/$1 [R=301,L] // If its true send the user to http://habboxforum.com/(WHATEVER (http://habboxforum.com/%28WHATEVER) FILE THEY WERE TRYING TO LOOK AT)

So thats is for the tutorial. If you need help just plonk a post below and I will try and help you!!!

Thanks,
Jake

[/i]

:Edzy
31-05-2007, 12:28 PM
not a bad tut at all +REP

Mr Macro
31-05-2007, 12:28 PM
<?php
header('Location: page.htm');
die();
?>
Simple. :)


Good tut though, rep+

:Liam
31-05-2007, 12:29 PM
You can just use the section Redirects in cpanel.

Sunny.
31-05-2007, 12:32 PM
You can just use the section Redirects in cpanel.
^^ Thas what i use :)

Florx
31-05-2007, 12:34 PM
wt if you use plesk OR if its on localhost.

:)

Mr Macro
31-05-2007, 12:36 PM
<?php
header('Location: page.htm');
die();
?>


Then use that.If its a HTML file, use your method :)

Aflux
31-05-2007, 12:42 PM
META?

Anywho, nice tutorial :)

Florx
31-05-2007, 12:46 PM
<meta http-equiv="refresh" content="0;url=link.html">

Don't use it though

Blob
31-05-2007, 12:49 PM
<meta http-equiv="refresh" content="0;url=link.html">

Don't use it though

Why? it doesnt harm you?

RYANNNNN
31-05-2007, 12:50 PM
The best redirect is 301, although it depends on your needs. Using a 301 redirect is like telling a search engine your page has moved. It also keeps PR intact.

Florx
31-05-2007, 12:50 PM
Its not search engine friendly

Mentor
31-05-2007, 10:27 PM
Why? it doesnt harm you?

Well it kinda does. It breaks back button, which degrades user experience, plus its negatively impacts Page rank

Blob
01-06-2007, 03:37 PM
Well it kinda does. It breaks back button, which degrades user experience, plus its negatively impacts Page rank

Surely if your redirecting someone to a new site they wouldnt press the back button as it will just lead them back to the page?

Mentor
01-06-2007, 05:46 PM
Surely if your redirecting someone to a new site they wouldnt press the back button as it will just lead them back to the page?
Eg. They go on search engine, follow a link. Get redirected. This aint what they want. click backbutton. Doesnt work.

Its bloody annoying when that happens and done in bad taste, hence why its ranked down by search engines.

Jazza
01-06-2007, 06:20 PM
You can just use the section Redirects in cpanel.

I was gonna say that lol

Want to hide these adverts? Register an account for free!