Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am looking for the most efficient way to redirect users to different web pages on my server using a keyword off of the main domain.

So http://www.example.com/keyword might take you to a longer URL like http://www.example.com/arts-and-culture/articles/index.html

Currently I am using an Apache redirect in the http.conf file

Redirect /keyword http://www.example.com/arts-and-culture/articles/index.html

I am wondering if this is the best and most efficient way to accomplish a redirect. I also could do a redirect in the .htaccess file I believe and also do something like a PHP redirect like

 header( 'Location: http://www.yoursite.com/new_page.html' ) ;

I just want the most efficient way of doing a redirect that is not harmful to SEO or tracking via Google Analytics.

Can anyone give me a heads up on what they are using and why?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

If the pages have already been published you'll want to use a 301 redirect as that will transfer all links and their SEO benefit from the old URL to the new URL (FYI, a small amount of of PageRank and link value is lost).

This can be in the http.conf file, .htaccess, or PHP.

http.conf/.htaccess example

redirect 301 /old_page.html http://www.yoursite.com/new_page.html

PHP example:

header( 'Location: http://www.yoursite.com/new_page.html', true, 301 ) ;

By doing this on the server side you won't trigger Google Analytics to track the old URL. However, if you do want to use Google Analytics to track those redirects you will need to use client side redirects.

JavaScript example:

<script type="text/javascript">
<!--
// This goes after the GA code
window.location = "http://www.yoursite.com/new_page.html";
//-->
</script>

Or with a 5 second delay (this can go before or after the GA code)

<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
    window.location = "http://www.yoursite.com/new_page.html";
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, please update your bookmarks to our new 
location!</p>

</body>
</html>

META Tag example

<!-- content="5" will redirect the page in 5 seconds-->
<meta http-equiv="refresh" content="5">

HTTP header example:

(The 5 is the number of secods to wait to redirect
Refresh: 5; url=http://http://www.yoursite.com/new_page.html/

If those pages have not be published you can use mod_rewrite to make the URLs more user-friendly:

RewriteEngine on
RewriteRule ^([^/\.]+)?$ example.com/long-url/article/$1/index.html [L]
share|improve this answer
    
My issue is more or less just ease of use: example.com/keyword is easier to remember than example.com/long-url/article/keyword/index.html. So I am wondering what the best way is to accomplish this? –  mmundiff Oct 18 '11 at 15:05
    
If the long URLs already exist, any of the above methods will work fine as you will not lose the value of any links you have acquired thus far. If you haven't published this content yet, you can use mod_rewrite which will not involve any redirecting. I'll add an example of that now. –  John Conde Oct 18 '11 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.