regex - How does mod_rewrite send parameters? -


i make file "page.php" name , wrote code in it:

echo $_get['product']; 

and in ".htaccess" wrote code:

rewriteengine on rewriterule (.*)$ page.php?product=$1 [l] 

all of these files in "apache" folder in localhost. problem url http://localhost/apache/book instead of "book" echos "page.php" have no idea why.

it happening because rule looping twice,

  1. first time /apache/book uri
  2. second time /page.php

to avoid situation need conditions this:

# skip rule valid files rewritecond %{request_filename} !-f # skip rule valid directories rewritecond %{request_filename} !-d 

so combining /apache/.htaccess this:

rewriteengine on rewritebase /apache/  # skip rule valid files rewritecond %{request_filename} !-f # skip rule valid directories rewritecond %{request_filename} !-d rewriterule ^(.+)$ page.php?product=$1 [l,qsa] 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -