Rewrite condition without RewriteCond?

I wrote a regex for a rewrite rule that includes a negative lookahead to replace the rewriteCond line, because WordPress only accepts two values: pattern -> substitution. No conditionals.

It should find findme.html _here, regardless of where it’s requested to be:
mydomain.com/_here/findme.html

(Sorry, I can’t modify the swf which will request findme.html in the wrong places)

So, given findme.html could be requested to be in, e.g. (always in the same directory than the page that called it):

mydomain.com/findme.html
mydomain.com/directory/findme.html
mydomain.com/directory/subdirectory/findme.html?someparam=3

The rewrite should make them all (query string could stay, though)

mydomain.com/_here/findme.html

So, I made a rewrite rule that Wordpress will accept, with a negative lookahead so it only matches URLs which dont contain “_here/” already, as follow

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^.*?(?!_here/)findme\\.html$ /_here/findme.html [R=301,L]

The problem is it LOOPS.

What did I miss?

(I tested it with no other code in the .htaccess file, still looping)

PD: 1 tag allowed for each thread?
Do you want topics to be found or bury them?

SZ,

You don’t care what WordPress likes until the URI is delivered to Apache to serve - which is after mod_rewrite has a crack at it.

Okay, problem is to redirect any and all findme.html requests (with their query string) to _here/findme.html.

That’s easy to do (and make loop as you’ve discovered) by

RewriteRule findme.html$ /_here/findme.html [L]

To prevent looping, you’d merely exclude the _here subdirectory in a RewriteCond like

RewriteCond %{REQUEST_URI} !^_here/

Viola!

Regards,

DK