SEO/PHP: How to Convert Form-Submit URL (Get-Method) without Javascript SEO-Friendly?
forms, javascript, php, seo
Solution
I am for the following technique because
- it's a guessable URI to search "via the address bar"
- it's always a good thing to redirect while responding to a POST-request, to avoid awkward "want to send POST information again?"-alerts when the user tries to go back via the browser's back button
- it's simply easier to see what I searched for if the URI is clean of hidden values, value of submit-button etc.
Here goes:
<?php
//receiving page
if(isset($_GET['name_of_submit'], $_GET['search_phrase'])) {
header("Location: /address_to_this_script/".$_GET['search_phrase']);
die;
}
if(isset($_GET['search_phrase'])) {
// handle search and validation here, don't forget to escape it!
}
Problem
and actually i convert the url with javascript ``` <script type="text/javascript"> $(document).ready(function() { $('.search-form').submit(function() { var value = $('.search-form input:text').val(); value = value = value.replace(/\W/,''); // replace window.location.href = value + "-keyword" + ".html"; return false; }); }); </script> ``` is there a method to convert the url seo-friendly without javascript? maybe with php?