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.
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
| Context |
Name |
Description |
|
S
V
D
.h
|
mod_linkfreeze |
forces mod_linkfreeze to start automatic links replacement on pages
|
|
S
V
D
.h
|
content-type-charset |
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
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
By default mod_linkfreeze does not process links in absolute format
<a href="http://localhost/default.aspx?param=val#comment">link</a>
because most of them point to external resources that won't probably be able
to processed them correctly. But if
A flag is specified after the rule, such links will be frozen.
Note that mod_linkfreeze compares
SERVER_NAME server variable with the host name for the link
<a href="http://localhost/default.aspx?param=val#comment">link</a>
to freeze links to local site only.
- Lowercase or L — Lower case all links before transformation
- MoveExt or M — Move file extension to the end of URL
Example
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" [ MoveExt ]
The above rule will convert
<a href="/default.aspx?param=val#comment">link</a>
to
<a href="/default-param-val.htm#comment">link</a>
Example
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm"
The above rule will convert
<a href="/default.aspx?param=val#comment">link</a>
to
<a href="/default.htm-param-val#comment">link</a>
- NoCheckFile or NF — Do not check for physical file
If the request is
http://localhost/default-param-val.html
and such file physically exists, mod_linkfreeze will show it.
With
NoCheckFile flag after the rule
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" [MoveExt, NoCheckFile]
the link will be de-frozen anyway and the user will get response from
http://localhost/default.aspx?param=val.
This is not the most reliable solution, but it works much faster because file
existence check is omitted.
- 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
mod_linkfreeze will perform redirect to new style URL to avoid duplicate content penalty if:
- the old-format URL is requested;
Example
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" [ MoveExt, Redirect ]
With the above rule in place the request to
http://localhost/default.aspx?param=val#comment
will be 301-redirected to
http://localhost/default-param-val.html#comment.
- the requested URL has wrong format (incorrect order of parameters; old
extension; parameters out of Params list (see below); etc.).
Example
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" [ MoveExt, Redirect, Params="id|page" ]
With the above rule in place the request to
http://localhost/default.aspx?id=val&other=val2
or
http://localhost/default-id-val-other-val2.html
will be 301-redirected to
http://localhost/default-id-val.html?other=val2,
which means that all unwanted parameters are left outside the Google-indexed
part of the URL (in the query string) and hence won't harm your pagerank.
- Params="param1|param2| param3..." — Freeze specified parameters only
Example
SetEnv mod_linkfreeze
LinkFreezeRule --- "aspx=htm" [MoveExt, Params="aaa|bbb"]
With the above rule in place only "aaa" and "bbb" parameters will be frozen. So,
<a href="/default.aspx?aaa=val1&otherParam=etc">link</a>
will become
<a href="/default-aaa-val1.htm?otherParam=etc">link</a>.
mod_linkfreeze performs sorting of parameters before freezing to avoid duplicate
content penalty (also true for Redirect).
The script doesn't care what the order of parameters is:
<a href="/default.aspx?aaa=val&bbb=val">link</a>
<a href="/default.aspx?bbb=val&aaa=val">link</a>
But for the file-system these are different filenames that will then return the same content:
<a href="/default-bbb-val-aaa-val.htm">link</a>
<a href="/default-aaa-val-bbb-val.htm">link</a>
mod_linkfreeze guarantees the same parameters order in both cases:
<a href="/default-aaa-val-bbb-val.htm">link</a>