[CentOS] CentOS 6.8 Apache-2.2.15-53 re-write question

Sat May 28 19:35:03 UTC 2016
Walter H. <Walter.H at mathemainzel.info>

On 28.05.2016 21:03, Paul R. Ganci wrote:
> I was wondering if somebody could help me with an Apache re-write 
> rule. Apparently CentOS 6.8 is running apache-2.2.15-53. I am trying
> to redirect all pages except for two pages. The apache rewrite 
> directives in the httpd config are:
>
> RewriteEngine on
> RewriteCond %{REQUEST_URI}!^/test/
> RewriteCond %{REQUEST_URI}!^/my-folder/
> RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
>
> These commands should cause all requests to get re-directed to 
> www.newdomain.com except for those with a /test or /my-folder on the 
> end of the
> URL. However when I place these commands into the the httpd config 
> apache spits out this error message:
>
^ is the beginning marker of a regular expression;
are you sure you want at the end?

RewriteEngine on
RewriteCond %{REQUEST_URI}   !^/test/
RewriteCond %{REQUEST_URI}   !^/my-folder/
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

> Starting httpd: Syntax error on line 31 of 
> /etc/httpd/conf.d/olddomain.conf:
> RewriteCond: bad argument line '%{REQUEST_URI}!^/test/
caused by missing whitespace
> I have of course renamed the real config parameters. Can somebody tell 
> me if these directives only work in apache-2.4 and if so how do I do the
> same thing in apache-2.2? If these directives should work in 
> apache-2.2 is this an apache problem?
these should work in 2.2.x, too;