RewriteRule test.htm$ /number?npa=$1&nxx=$2&num=$3?

My eventual goal is to take this url:

http://www.domain.com/number?npa=218&nxx=260&num=0027

into this:

http://www.domain.com/number/218-260-0027.htm

Everything I tried with .htaccess does not work. I am trying to start simple. mod_rewrite is working on the server.

Why does this not work???

RewriteRule test.htm$  /number?npa=$1&nxx=$2&num=$3 [L] 

bp,

First, WELCOME to SitePoint’s Apache forum!

Second, the short answer to your question is that you do not know enough to use mod_rewrite. Rather than repeat my tutorial here, please read the REGEX section of the tutorial Article linked in my signature.

My question to you, for your RewriteRule, is where do you generate $1, $2 and $3? Moreover, you’re looking at the whole problem backassward as you MUST redirect to something Apache CAN serve which, by the looks of things, you’re not doing. Again, though, the tutorial has helped many members and I’m sure it can help you, too.

Regards,

DK

I don’t understand. It is a one line solution? I thought someone might jump in and write out a rule that should work.

The url is being generated by Wordpress, with a custom page underneath.

Is the issue that mod_rewrite needs a file extension in order for it to work??? Hence, my url ends with “number?”…

I use mod_rewrite once in a while. Appreciate your help.

Yes, I already Googled a lot. I searched before I posted.

bp,

If this is a WordPress problem, then I recommend NOT messing with it as doing so will BREAK the navigation. Know that WP “reads” the original request, parses it to determine which of its modules to use then fetches them to do the work to create your page.

Look in WP’s administration section as there are options to change the URI format.

As an aside, only your .htm “link” above can actually be served by Apache but ONLY if there is such a file in existence (which, if you’re using WP, I’ll guarantee it does NOT exist).

Therefore, to understand what mod_rewrite does, I recommend you read the tutorial. If you merely want a “one liner” to solve an indeterminate problem, you’ve come to the wrong place as I’m here to help members LEARN, not to feed “script kiddies.”

Please note that I’m NOT calling you a “script kiddie,” I’m just saying that I don’t do coding for members.

Regards,

DK