SEO / PHP: how to convert form URL (Get-Method) without Javascript SEO-Friendly?

and actually i am converting the url using 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 way to convert seo-friendly url without javascript? perhaps with php?

+3
source share
3 answers

I use the following technique because

  • this is a valid URI for searching through the address bar
  • It is always useful to forward when replying to a POST request to avoid the inconvenience of β€œwant to send POST information again?” - warns when the user tries to return through the back button of the browser.
  • , , URI , ..

:

<?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!
}
+4

, , , - URL-, URL- SEO . onclick, URL- SEO javascript, Google .

, , - db, " " ( seo), , .

0

- , .

0

Source: https://habr.com/ru/post/1735153/


All Articles