最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

SEOPHP: How to Convert Form-Submit URL (Get-Method) without Javascript SEO-Friendly? - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question asked Mar 3, 2010 at 0:27 elmaselmas 692 silver badges7 bronze badges 1
  • 1 You could always accept the POST at index.php and 301 redirect to <searchkeyword>-keyword.html from there. The only reason to change the action attribute in-page is if you want to save a request. – Frank Farmer Commented Mar 3, 2010 at 2:03
Add a ment  | 

3 Answers 3

Reset to default 4

I am for the following technique because

  1. it's a guessable URI to search "via the address bar"
  2. 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
  3. 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!
}

This is what I would do too, because if anyone links to either URL the link juice will always flow down in the SEO Url eventually. You could use an onclick to take the user to an SEO URL in javascript, but google wont follow it.

One thing you could do is to store those searches in a db and then have them as "related links" (the seo versions) linked to from each page on your site, this way they will get spidered.

The best way is to remove special characters and replace it by the page, category and section names. Regards

发布评论

评论列表(0)

  1. 暂无评论