php - .htaccess and $_GET confusion -
i have rather strange situation here. have 3 line .htaccess is:
rewriteengine on rewriterule ^/([a-za-z0-9-]+)/?$ $1.php [nc] rewriterule ^/signup/([a-za-z0-9-]+)/?$ /signup.php?step=$1 [l,qsa]
and simple algorithm:
if (empty($_get["step"])) { don't } else { if ($_get["step"] == 'step2') { } ..
now if use signup.php?step=step2
expected result, if use signup/step2/
, var_dump( $_get )
returns 0.
i tried similar threads found here, can't find working. might walking circles around can't notice.
if you're using apache 2.0 or higher, must strip off leading /
's pattern, because rewrite engine strips them off before applying rules in per directory context, , rules in htaccess files per directory (i.e. directory htaccess files in).
additionally, if intend append .php
extension end, must check if file exists, otherwise 404 lead 500 server error. should last:
rewriteengine on rewriterule ^signup/([a-za-z0-9-]+)/?$ /signup.php?step=$1 [l,qsa] rewritecond %{document_root}/$1.php -f rewriterule ^([a-za-z0-9-]+)/?$ $1.php [l]
Comments
Post a Comment