How can I insert a rule in the header of all pages without the fancyhdr package? Is it necessary to use the fancyhdr package?

-
Welcome to TeX.SE. It is always best to compose a fully compilable MWE that illustrates the problem so that the solution can be customized to your situation. Basically, show us that you have so far. –  Peter Grill Feb 25 '12 at 21:39
"doesn't have the same length of the text": is this the only reason why you don't want to use fancyhdr? I don't see anything wrong with the length of the header rules when I use fancyhdr. –  JohnJamesSmith Feb 25 '12 at 22:06

Perhaps, in an attempt to diagnose the problem prematurely (and too long for a comment without visualization), here's a possible scenario causing the difference in length between the header rule and the text block: Choosing the page style before modifying the page layout dimensions.

In the minimal example below, the page style is set to fancy (from the fancyhdr package) before using geometry to set the page layout.

\documentclass{article}%
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr

Setting the page style to fancy after loading geometry yields