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,
- first time
/apache/book
uri - 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
Post a Comment