I created a small search engine (html call for php to do the query) to search a mysql database. For example, if you input 'var1' in the search box of the html, the resulting url shown on my website will be http/www.mysite.com/search.php?search=var1&submit=submit
I am trying to figure out how to change the shown url to www.mysite.com/var1, instead.
Rewriting is for inbound URLs (those coming from the address bar of the browser) not for outbound URLs (those that result from coming from a form or server side language).
What you have will take the 2nd form you want, the one with DIR/var1 in it, and change it to the original format (search.php?search=var1) not the other way around.
__________________
Dave .... HostMonster for all of your hosting needs
I have a similar question. So how do I write the rule so that the incoming /DIR/var1 will be turned into /search.php?search=var1&submit=submit?
Quote:
Originally Posted by djm0219
Rewriting is for inbound URLs (those coming from the address bar of the browser) not for outbound URLs (those that result from coming from a form or server side language).
What you have will take the 2nd form you want, the one with DIR/var1 in it, and change it to the original format (search.php?search=var1) not the other way around.
Last edited by toolglutton; 01-22-2011 at 04:57 AM..
I do not know how to do that, but I am sure it is possible. For example www.dtcsearch.com.
Quote:
Originally Posted by djm0219
Rewriting is for inbound URLs (those coming from the address bar of the browser) not for outbound URLs (those that result from coming from a form or server side language).
What you have will take the 2nd form you want, the one with DIR/var1 in it, and change it to the original format (search.php?search=var1) not the other way around.
Last edited by toolglutton; 01-21-2011 at 10:47 PM..
Camaross, is this related to the problem solved in your other thread? Or is it new? If it's related can you update your question based on what we figured out, please. It would help me address your question.
__________________ Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
For this thread, I am trying to see if it is possible to rewrite php generated url from 'www.mysite.com/search.php?search=var1&submit=submit' to 'www.mysite.com/var1'?
Thanks.
[QUOTE=ShaneC;1043509]Camaross, is this related to the problem solved in your other thread? Or is it new? If it's related can you update your question based on what we figured out, please. It would help me address your question.
__________________ Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
Thank you for the nice solution. That's refreshing.
I am using a search box (<form action="search.php" method="get" >) inside a html to call for search.php to do the query. How do I modify them so that I can submit the form in a clean url, http://mysite.com/var1/submit?
Quote:
Originally Posted by ShaneC
You shouldn't ever need to rewrite from a PHP Query String to the nice version.
Thank you for the nice solution. That's refreshing.
I am using a search box (<form action="search.php" method="get" >) to call for search.php to do the query. How do I modify it so that I can submit the form in a clean url, http://mysite.com/var1/submit?
Yup! When it gets to search.php you can just do something like this in your PHP:
PHP Code:
<?php
if( isset( $_POST['submit'] ) ){ // The form has been submitted to this address // Do all the neccessary POST stuff here. }else{ // Do all the non-POST stuff here }
?>
__________________ Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
The url does not change. Actually, the submit input is not that important. Inside php, I can remove everything related to $_GET['submit'], and they still work fine.
Don't you think the search.php?search=var1&submit=submit is generated by the html?
Quote:
Originally Posted by ShaneC
Yup! When it gets to search.php you can just do something like this in your PHP:
PHP Code:
<?php
if( isset( $_POST['submit'] ) ){
// The form has been submitted to this address
// Do all the neccessary POST stuff here.
}else{
// Do all the non-POST stuff here
}
This will then take whatever has been submitted through the form and then redirect your browser to http://mysite.com/<Search Value>.
__________________ Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
The Following 2 Users Say Thank You to ShaneC For This Useful Post: