php - .htacess rewrite url when using get values -
i'm trying turn http://www.starsqa.com/lala.php?fname=bob http://starsqa.com/lala/bob
<form action="lala.php" method="get"> name: <input type="text" name="fname"> <input type="submit"> </form> welcome <?php echo $_get["fname"]; ?>.<br> i tried on .htaccess, nothing happened
redirect 302 /lala.php?fname=bob http://www.starsqa.com/lala/bob.php is possible?
if want send visitors http://www.starsqa.com/lala/bob http://www.starsqa.com/lala.php?fname=bob:
rewritecond %{query_string} ^$ rewriterule ^/lala/bob$ /lala.php?fname=bob [l,qsa] rewritecond %{query_string} ^$ rewriterule ^/lala/bob/$ /lala.php?fname=bob [l] if want general pattern fname can name, try this:
rewritecond %{query_string} ^$ rewriterule ^/lala/([a-za-z0-9:\@.\-\+]{1,100})$ /lala.php?fname=$1 [l,qsa] rewritecond %{query_string} ^$ rewriterule ^/lala/([a-za-z0-9:\@.\-\+]{1,100})/$ /lala.php?fname=$1 [l] if instead want send visitors http://www.starsqa.com/lala.php?fname=bob http://www.starsqa.com/lala/bob :
rewritecond %{query_string} ^$ rewriterule ^/lala.php?fname=bob$ /lala/bob [l] and similarly, more general pattern be:
rewritecond %{query_string} ^$ rewriterule ^/lala.php?fname=([a-za-z0-9:\@.\-\+]{1,100})$ /lala.php/$1 [l] last example (sending user starsqa.com/jen-lilley-contact starsqa.com/contact-id=6) :
rewritecond %{query_string} ^$ rewriterule ^/jen-lilley-contact$ /contact-id=6 [l] by way, not forget restart apache.
how restart apache depends on platform configuration. os running on?
Comments
Post a Comment