Skip to content


Redirecting Dynamic Pages To Static Pages / URLs

Why Redirect?

You do not want to create new pages on your site using the same content as an old page without setting up a 301 redirect.  Specifically – creating a brand new page that creates a brand new URL string where each new page contains the same content as an existing page – should be examined.

Google and every other search engine want to find ONE VERSION of a page.  The search engines do NOT want to find the same content on multiple pages on your site, much less on another site.  So you need to set a canonical URL (serve http://www.site.com or http://site.com, but not both), check my blog post linked below for the how-to steps.

And if you launch a new version of a page, change the theme, or do anything and that changes the URL – such as moving from a dynamic page to a static page – then you need to implement 301 redirects accordingly for each and every page.  If you move a page from one directory to another, you need to implement 301 redirects accordingly.  If you rename a file from “contact-us.html” to “contact-us.php” you need to implement 301 redirects accordingly.  You get the point – if anything changes in the URL string for a page of content, you need to implement some helpful 301 redirects.  The search engines and your site users will thank you for it.

How To Redirect:

Dynamic pages, in all their helpful glory, sometimes need to be changed or updated or moved or renamed or redirected.  Simply changing the name or location is simple – you just make the appropriate code change or database update and POOF! you get your new page and likewise a new URL.

Dynamic Page URL: www.site.com/index.php?page=867-5309

New Page – Static Page – Moved Page URL: www.site.com/theme/867-5309.html

If you simply launch the theme/867-5309.html page and leave behind the index.php?page= version, you stand to have 2 different versions of the SAME CONTENT on your site.  Duplicate content, while not being a necessary deathnail in such a small instance as between 2 pages, should still be avoided whenever possible.  It’s just good developmental practice too.

Worse yet, suppose you launch the theme/867-5309.html page and simply stop serving the old index.php?page= version.  That leaves behind a 404 error when Google, or a user that’s bookmarked the page, tries to browse to the dynamic page.  404s are ok – at least better than 500 errors – but what’s a better solution – a more helpful solution – a good practice solution – is to 301 redirect the old dynamic page to the new page.

Simply 301 redirecting pages is pretty simple.  There’s a ton of information all over the web on how to do it.  I cover how to 301 redirect users to a canonical domain here, and 301 redirecting dynamic pages to a new, more static type URL string isn’t far off.

There are number of things you must consider, namely the syntax of your .htaccess file must be 100.0000% perfect, and you must have Apache’s mod_rewrite turned ON.  Chances are you’re tech savvy enough to handle that, you know someone who is, or your hosting provider can do it for you.

I like .htaccess because I like Linux.  I also like .htaccess because it’s pretty easy to manage.  If you don’t have an .htaccess file set up, check the Linux steps I outline in my 301 redirect post linked above.

After you’ve got your handy .htaccess file living in your domain’s home space, it’s high-time to get to re-writing.

(pending you’re 301 redirecting all of your domain requests to the www. version of your domain – having set up a Canonical Domain)

Here’s the helpful code you’ll need to do for each dynamic page you’re moving to a static version:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yoursiteurl.com
RewriteCond %{QUERY_STRING} ^page=867-5309$ [NC]
RewriteRule ^(.*)$ http://www.yoursiteurl.com/theme/867-5309.html? [R=301,L]

Let’s break it down a bit, shall we?

1st Line, turn the RewriteEngine On – pretty important and must be done for every instance.  Again, you’ll need these 4 lines of code for every dynamic page getting moved/updated/renamed.

2nd Line, a RewriteCond (rewrite condition), again pending you’ve specified the www. version of your URL, you’re making a declaration of sorts that what you’re about to do should be applied to this specified HTTP host.

3rd Line, another RewriteCond (rewrite condition), this is where some of the magic starts happening. That “%{QUERY_STRING} ^actually takes the place of the “?” in the dynamic URL – so to speak.  And the QUERY_STRING must be capitalized. There is a space before the % and ^ as well that are required.  Again, the syntax is ultra-important! That $ at the end is VERY important too as well as the [NC] at the end.  All you really need to do is replace the variable and variable values, in this case “page=867-5309 you use in your URLs for this line.

4th Line, this is where the magic is finishing up the redirect for you.  Now that you’ve got your rewrite conditions set up, it’s time to implement them somewhere with a rule, or RewriteRule.  The ^(.*)$ basically says we’ll be using everything we captured in the last rule, between the ^ and the $, and the rewrite is going to go to this new URL. There is a space before the  of the % and ^ and after the $ that are all required. A character I cannot stress the importance of is the trailing ? towards the end of the new/static URL.  That is very important in connecting the Conditions to the Rule.

There we have it – how to 301 redirect dynamic URLs and dynamic pages to new static pages or new file locations.  If you copy those 4 lines and paste them into something simple like Notepad, you’ll see all the spaces and characters just fine.  Remember, turn Apache mod_rewrite ON, use 100.0000% perfect syntax, and use all 4 lines for every page needing a redirect/update.

Posted in Work - SEO/SEM.

Tagged with , , , , , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.