RewriteRule for query string

I can’t seem to get a RewriteRule to work to convert from WordPress default URL formats (including query strings like ?p=100) to the format that MovableType uses, the URL that points clearly to an actual file.

I want to go from:


I’ve simplified all the way to this:
RewriteRule ^/?p=100$ /old-wp-urls/p/100/file-name-for-p100.html [R,L]

but it just does not seem to get applied. The file path is correct and the destination file exists.

My root index.html file has a Refresh command. Thinking this might get in the way of the RewriteRule, I removed it but then the system acts like this index file is missing even though it shouldn’t need it and still does not map to the one I’m asking for.

Any help is greatly appreciated ~ thanks.

[quote]I’ve simplified all the way to this:
RewriteRule ^/?p=100$ /old-wp-urls/p/100/file-name-for-p100.html [R,L][/quote]
I think you overlooked this part of the documentation for mod_rewrite module for the RewriteRule directive:

"Note: Query String

The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable. You can, however, create URLs in the substitution string, containing a query string part…"

I hope that clears things up for you!

Also the value of the QUERY_STRING variable will not start with the question mark either.

:cool: -//-

well, that is a clue. thank you. however I am still not seeing this work.

I’ve reduced my solution to these simple attempts:

RewriteCond %{QUERY_STRING} ^§=(\d+)$
RewriteRule ^/$$1/$2/thisparticularfile.html

RewriteCond %{QUERY_STRING} ^p=(\d+)$
RewriteRule ^/$$1/thisparticularfile.html

RewriteCond %{QUERY_STRING} ^§=(\d+)$
RewriteRule ^/$

I am turning RewriteEngine on and off around these sets of commands.

I’ve tripledouble checked that the destination files exist as they are specified here.

I get my default index file to show up. It appears the Condition I’m looking for is never true however sometimes when I mess up the syntax, I get the error suggesting I talk to my sysadmin, so I know it’s paying at least some attention to what I’m doing.

I’m using IE and Firefox because I know I’ve run into weirdnesses with cacheing and otherwise before.

Yes, I had read the apache docs before and yes I had not picked up on that point. it’s like drinking from a firehose. I appreciate help from those who want to help. I do the same in the fields where I can offer something. I don’t come to this forum as a first response. this area is not my strength and I’ll be the first to admit it.

in earlier more basic testing, I satisfied myself that the server I’m on requires the destination path to be absolute. This doesn’t seem to be the case for many many examples all over the web. I wonder if there is more to the RewriteCond requirements here at Dreamhost.