apache - Htaccess rewrite condicion url with dash -


i'm having trouble make htaccess work

rewriteengine on  rewritecond %{request_filename} !-f rewritecond %{request_uri} /([temp|ox|cond|new-url]+)/ rewriterule ^([a-za-z]+)/([a-za-z]+)$ graph.php?grap=$1&time=$2 [nc,l] 

before adding new-url condition rewrite condition working ok

i tried put new\-url , new/-url doesn't work either

what i'm doing wrong?

i think there few errors in file.

first, ([temp|ox|cond|new-url]+) same ([cdelmnoprtuwx|-]+). here you're searching characters, not words. if understand, you're looking urls starting either /temp/, /ox/, /cond/ or new-url. use condition:

rewritecond %{request_uri} ^/(temp|ox|cond|new-url)/ 

second, when match new-url, there's dash. next rule doesn't accept dash! change one:

rewriterule ^([a-z-]+)/([a-z-]+)$ graph.php?grap=$1&time=$2 [nc,l] 

notes:

  • i used [a-z] instead of [a-za-z] rule doesn't take case in account ([nc])
  • i added dash @ end of character range: [a-z-]

Comments