1

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?

1 Answer 1

0

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]
2
  • 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, 2011 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, 2011 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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