PHP $_GET .htaccess rewrite -


htaccess:

rewriteengine on rewriterule ^test/ test.php rewriterule ^test/success/ test.php?success 

test.php:

<?php if(isset($_get['success']))     echo "success"; else {     echo "nothing set"; } ?> 

when try access test.php /test.php?success works , echos "success". want work same way overwritten in htaccess. want echo message when open /test/success/. if possible, correct?

.htaccess rewrite rules read top bottom,

if apply input string, get

  • start /test/success/
  • matches rewriterule ^test/ test.php becomes test.php
  • test.php doesn't match rewriterule ^test/success/ test.php?success

we end test.php.

however, isn't want, because want last url rewrites test.php?success instead of other file. there easy fix problem, simple swap 2 lines of rewrite rules longer 1 listed first

resulting .htaccess file:

rewriteengine on  rewriterule ^test/success/ test.php?success  rewriterule ^test/ test.php 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -