regex - Apache redirect if string contains anything other than letters and numbers -


so have rewrite condition, takes %1 previous line, , should redirect if string contains other letters , numbers. but, reason, works if string begins , ends letters or numbers (allowing middle anything)

heres condition:

rewritecond %1 !^[a-z0-9]+ [nc] rewriterule ^ http://www.example.com/nomatch 

so, in case, wont redirect if %1 hdsuf38//*&hdsfghj73

anyone know i'm missing?

two changes

  • add small letters character sequence.

  • add anchor $ matching continued till end of string

regex can be

^[a-za-z0-9]+$  

regex demo

rule as

rewritecond %1 !^[a-za-z0-9]+$  [nc] rewriterule ^ http://www.example.com/nomatch 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -