.htaccess - mod_reweite htaccess not work with a point in var -


i creating mod_rewrite rule

rewritecond %{script_filename} !-d rewritecond %{script_filename}\.php !-f rewriterule ^(.*)$ ./page.php?key=$1 

it works! want this:

www.site.com/var1.var2.var3 

(variables separated point) separated - or _ no problems, if put point not work why?

i assume trying rule this

rewriterule ^(.*).(.*).(.*)$ ./page.php?key=$1&key2=$2&key3=$3 

but should remember escape dots want interpret periods. there many ways right here simple way if new .htaccess files:

rewriteengine on rewritebase / # skip existing files or directories rewritecond %{script_filename} -d [or] rewritecond %{script_filename} -f rewriterule ^ - [l] # add default php extension when appropriate rewritecond %{script_filename}.php -f rewriterule ^.* $0.php [l] # pick 1,2 , 3 parameter versions rewriterule ^(.*?)\.^(.*?)\.(.*)$ page.php?key=$1&key2=$2&key3=$3 [qsa,l] rewriterule ^(.*?)\.(.*?)$ page.php?key=$11&key2=$2 [qsa,l] rewriterule ^(.*?)\.$ page.php?key=$1 [qsa,l] 

note:

  • the first rule uses "^" pattern matches , "-" means don't replace it.
  • the second uses $0 means entire match pattern
  • rule 3-5 match 3,2,1 parameter options
  • the [l] (last) flag means skip rest of rules
  • you need qsa flag use other parameters.

the reason splitting existance check in need handle files such css , image (png/gif/png) files application syntax.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -