mod_linkfreeze

Overview

mod_linkfreeze module provides extended toolset for pattern-based transformation of links on pages to SEO-friendly format.

In general "freezing" idea is based on HTML content modification. Once you've written special rules, the module would carefully modify every hyperlink inside each web-site page if the link matches the rules pattern(s). In a word, mod_linkfreeze turns dynamic links to the static ones. It is a primary idea of the module and at the same time a good SEO practice as long as search robots work much better with static references. And the most interesting thing here—you don't need to modify any part of existent code. The user goes to a web-site and IIS serves the request through the web-site engine. It doesn't matter what the engine is. It can be WordPress, CakePHP or even simple HTML. The important part is that the engine returns HTML response within hyperlinks and then mod_linkfreeze catches and processes the response according to its rules. Dynamic links become static and the user finally gets requested page.

WARNING: Built in IIS compression should be disabled in order for link replacement function to work. You are free to enable compression using Ape's mod_gzip module.

Quick start

  • Replace all links http://www.exaple.com/ default.aspx?param1=valueA to http://www.exaple.com/ default-param1-valueA.htm :
    #put these rules into the root .htaccess file
    SetEnv mod_linkfreeze
    LinkFreezeRule --- "aspx=htm" [ AbsLinks,MoveExt ]
  • Freeze only FID and TID parameters , redirect old-style requests to the frozen ones, ignore real files with *.htm extension (for better for performance):

    #put these rules into the /forum/.htaccess file
    SetEnv mod_linkfreeze
    LinkFreezeRule --- "asp=htm" [ MoveExt, Redirect, NoCheckFile,Params="FID|TID" ]

    This rule is useful for freezing forums (for example Web Wiz Forums engine):
    http://www.helicontech.com/forum/forum_topics.asp?FID=10 http://www.helicontech.com/forum/forum_topics-FID-10.htm
    http://www.helicontech.com/forum/forum_posts.asp?TID=14366 http://www.helicontech.com/forum/forum_posts-TID-14366.htm
    where FID is Forum ID and TID is Thread ID.

  • Migration from LinkFreeze product to mod_linkfreeze is easy but may be unobvious:
    LinkFreeze syntax:
    / ~~~ [MoveExt]
    Corresponding mod_linkfreeze syntax:
    SetEnv mod_linkfreeze
    LinkFreezeRule ~~~ "*" [ NoSort, MoveExt ]

Related articles and topics

Environment variables

Name Context Description
mod_linkfreeze S V D .h forces mod_linkfreeze to start automatic links replacement on pages
content-type-charset S V D .h allows to explicitly specify the charset value for Content-Type header to be used by mod_linkfreeze

Examples

This is how you can enable mod_linkfreeze for the entire site

# put this line into the .htaccess under the root of your site
SetEnv mod_linkfreeze

and exclude /admin folder from processing by mod_linkfreeze

# put this line into the .htaccess under /admin folder
UnsetEnv mod_linkfreeze

This same behavior may be achieved with one mod_setenvif directive:

# disables mod_linkfreeze for the current context
SetEnvif request_uri !/admin mod_linkfreeze

Note! Sometimes you'll need to explicitly specify the charset for mod_linkfreeze to use as some applications (like PHP) reset it bypassing IIS leaving Ape modules ignorant. To override Charset parameter value of Content-Type header use the following SetEnv line:

# sets Charset for mod_linkfreeze
SetEnv content-type-charset windows-1251

Exact names of charsets may be taken from here .

Directives

Name Context Description
LinkFreezeEngine S V D .h enables mod_linkfreeze functionality
LinkFreezePageSizeLimit S V D .h sets maximum page size to be processed by mod_linkfreeze
LinkFreezeRule S V D .h defines specific details of mod_linkfreeze behavior

LinkFreezeEngine

Enables mod_linkfreeze for the current context. It may be useful to disable mod_linkfreeze ( LinkFreezeEngine Off ) for the private areas of the site (such as /admin , /private ).

Syntax

LinkFreezeEngine On|Off

Default

LinkFreezeEngine On

Example

#put these rules into the httpd.conf file
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" [MoveExt]
<Location /admin>
  LinkFreezeEngine off
</Location>

LinkFreezePageSizeLimit

Sets the maximum page size in kilobytes that will be processed by mod_linkfreeze; the part of page exceeding the LinkFreezePageSizeLimit value will be left as is—links in that part won't be frozen (Google also doesn't enjoy parsing huge pages till the end). If the value is set to 0, the check for page size will not be performed.

Syntax

LinkFreezePageSizeLimit 2048|value

Example

LinkFreezePageSizeLimit 4096
SetEnv mod_linkfreeze 
LinkFreezeRule --- "aspx=htm" [ AbsLinks,MoveExt ]

LinkFreezeRule

Determines what links and in what way mod_linkfreeze will process. It is possible to use several LinkFreezeRule directives for the same context.

Syntax

LinkFreezeRule ?&= "old_ext=new_ext" OptionalLinkFilter [ FLAGS ]

Description

  • ?&= — any three characters allowed in filenames that will replace "?", "&" and "=" in the URL respectively.

    Note! It is advisable to use rarely used symbols as replacement characters, otherwise conflicts with the same characters in the URLs are inevitable. We recommend the following combinations: ---, ~~~, !!!, |||, ===, ///. The characters may also be combined, e.g.: -=-, !/=, etc.

  • "old_ext=new_ext" old_ext is the file extension to be replaced with new_ext

    Note! You can specify "*" character in case no extension modification is necessary.

    SetEnv mod_linkfreeze
    LinkFreezeRule --- "*"
  • LinkFilter — optional parameter that allows to finely configure what types of URLs to freeze. Regular expressions are possible

Example

SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" "^http://.*"

The above rule says that only URLs beginning with http:// (absolute links) must be processed.

Flags

Flags are used to apply additional conditions to LinkFreezeRule. The following flags are available:

  • AbsLinks or A — Transform Absolute links
  • Lowercase or L — Lower case all links before transformation
  • MoveExt or M — Move file extension to the end of URL
  • NoCheckFile or NF — Do not check for physical file
  • NoLinks or NL — Don't transform links on pages
    The links on pages won't be frozen; only incoming requests will be unfrozen.
  • NoRequests or NR — Don't decode incoming requests
    The incoming requests won't be unfrozen; only links on pages will be frozen.
  • NoSort or NS — Don't sort parameters in requests/links
    By default is disabled, i.e. parameters will be sorted alphabetically.
  • Redirect or R — Redirect old style requests to the static form
  • Params="param1|param2| param3..." — Freeze specified parameters only