Home RewriteRule negate (NOT) not working
Reply: 0

RewriteRule negate (NOT) not working

user843
1#
user843 Published in June 19, 2018, 6:24 pm

I am trying to do the following redirect:

any url such as:

/about/apple/1
/about/green
/about/apples
/about/pears/1

to:

/about/apple

using the following, which does not work:

RewriteRule ^about/(!apple) /about/apple [R=301,L]

The following test line works fine:

RewriteRule ^about/apples /about/apple [R=301,L]

I have tried:

RewriteRule ^about/!(apple) /about/apple [R=301,L]
RewriteRule ^about/(?!apple) /about/apple [R=301,L]

RewriteCond %{REQUEST_FILENAME} !(about/apple)
RewriteCond %{REQUEST_FILENAME} about(.*)
RewriteRule . /about/apple [R=301,L]

And also tried putting it into a rewritecond before hand, but nothing works.

Thanks.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313963 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO