.htaccess - redirect to different URL with .htacess or PHP -


i have form @ index.php takes in user input, includes , sends user input php file processing.

here code of index.php:

<?php if(isset($_get['q'])){     include_once "form.php";     exit(0); } ?> <!doctype html> <html lang="en">     <head>         <meta charset="utf-8" />         <title>search</title>     </head>     <body>         <form method="get">          <input type="text" name="q" />     </form>     </body>  </html> 

when 1 submits form, hitting enter when text-input focused, goes to

http://mysite.com/?q=textuserentered (if domain visited before) or http://mysite.com/index.php?q=textuserentered (if index.php visited before)

how can go http://mysite.com/form?q=textuserentered or http://mysite.com/index.php/form?q=textuserentered while still passing form data form.php

i prefer solution php, if way .htacess, please share.

i tried in beginning index.php , form.php, navigates url doesn't pass data form.php , navigates 404 error page.

if(!empty($_get['q'])) {     header("location: form?q=".rawurlencode($_get['q']));     exit; } 

i can't use action attribute because adding form.php value of action attribute make url http://mysite.com/form.php?q=userenteredtext not http://mysite.com/form?q=userenteredtext

just tell form send data, don't need redirect:

<form method="get" action="form.php"> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -