mod_rewrite rule for all urls except ones with some words
Posted
by
zlog
on Stack Overflow
See other posts from Stack Overflow
or by zlog
Published on 2011-03-16T05:44:25Z
Indexed on
2011/03/16
8:10 UTC
Read the original article
Hit count: 154
regex
|mod-rewrite
How do I write a mod_rewrite regulare expression rule that is the opposite of this:
^(.+)/path/(page1|page2)+$
ie, I want all pages except blah/path/page1 and blah/path/page2 to redirect to another path, where the x in blah/path/x is used in the new path.
For example, I'd like write a rewrite rule like:
RewriteRule some_regex /index.php?path/show/$1 [L]
where some_regex would pull out the last component of a url in the format:
/something/path/some_param
to redirect to
/index.php/path/show/some_param
I'm trying to use ! and [^] syntax, but I don't quite understand how these work, especially when they involve words not single characters.
© Stack Overflow or respective owner