How do I write a mod_rewrite rule that is the opposite of this:
RewriteRule ^(.+)/fixed_path/(page1|page2)([^/]+)$ /index.php?fixed_path/show/$2 [L]
That is, I want all pages in the form:
ignored_path/fixed_path/x
to redirect to
/index.php/fixed_path/show/x
where
- x is not equal to page1, page2 (and some other values)
- ignored_path is ignored in the new url
- fixed_path is carried over to the new url
ie, I want a rule to redirect everything in the form “ignored_path/fixed_path/x”, except specific pages (page1, page2, etc.), which are handled properly by my web app already.
I’m trying to use ! and [^] syntax, but I don’t quite understand how these work, especially when they involve words not single characters.
Assuming you want
blah/path/some_param(but not the two special cases:blah/path/page1andblah/path/page2), to be redirected to/path/show/some_param, which is then rewritten toindex.php?var=/path/show/some_param(so that the browser shows /path/show/some_param in the address bar), then the following should do the trick: