apo,
First, WELCOME to SitePoint’s Apache forum!
WHY ask at SitePoint when you’re using an article - even worse, using automated code generators - from other websites? I disagree with a couple of things in that “article” and loathe “generators” but let’s get to your problem.
If that’s the URI you’re attempting to redirect, WHERE are you trying to redirect it TO?
First thing that you MUST learn is that it’s YOUR job to link TO the "new format, i.e., mod_rewrite’s job is to convert from your NEW (SEO) format link TO the URI that Apache can serve. (Okay, a member a year and a half ago asked for help to redirect TO the new format then back to something Apache can serve but let’s learn to walk before we run, eh?)
I try to emphasize “specificity:” What is the format of the link which you are trying to redirect and what is the link you need to redirect that to? That will get you thinking about your NEW format link and whether it’s too vague (will redirect too much) and what characters you need to match.
Where you went wrong was trying to match the query string with your RewriteRule - it can’t be done (RewriteRules can only examine the {REQUEST_URI} variable; the {QUERY_STRING} can only be examined by a RewriteCond).
[COLOR="Gray"]Options +FollowSymLinks[/COLOR]
# That's probably already in your server's configuration file
RewriteEngine on
RewriteRule test(.*)\\.htm$ /index.php?id_al=$1
# No Last flag?
# test.htm to test{lotza_ garbage}.htm gets
# redirected to index.php with a query string of
# id_al={lotza_garbage}?
# Seriously? You don't know what your {lotza_garbage}
# consists of?
#
# THEN, using the leading / in the redirection forces Apache
# to look to the server's root directory BEFORE looking to
# your DocumentRoot for index.php.
The (.*) deserves special comment, i.e., a “standard rant:”
[standard rant #1][indent]The use of “lazy regex,” specifically the :kaioken: EVERYTHING :kaioken: atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is “greedy.” Unless you provide an “exit” from your redirection, you will ALWAYS end up in a loop![/indent][/standard rant #1]
In other words, ONLY use (.*) if you NEED to match NOTHING or EVERYTHING. This is the most abuse code because newbies do not understand regex. LEARN some regex (and the tutorial linked in my signature has helped many members with that simple task as well as offering quite a few sample code blocks to resolve specific problems).
Regards,
DK