简体   繁体   English

我该如何重写URL

[英]How can I rewrite URL in my case

I have read related Q&A's for this is question, but still I am confused on this, can somebody help me on this? 我已经阅读了有关此问题的问答,但是我对此仍然感到困惑,有人可以帮助我吗?
What I am doing : my url is : www.mysite.com/home.php I have two files: home.php and get_data.php, in home.php i am calling get_data.php with the use of jquery. 我正在做什么 :我的网址是:www.mysite.com/home.php我有两个文件:home.php和get_data.php,在home.php中,我使用jquery调用get_data.php。 the code for jquery is: jQuery的代码是:

$(document).ready(function(){
                   $("#btn_submit").bind('click', function(){
                   $.get('/get_data.php?tnm='+$('#tnm').val(), '', function(data){
                $('#get_info').html(data);
        });
    }); });

Here #tnm is name of the textbox & #get_info is the id of div tag. 这里的#tnm是文本框的名称,而#get_info是div标签的ID。 I am accessing $_GET['tnm'] in get_data.php. 我正在get_data.php中访问$ _GET ['tnm']。 What I want is : When I search username with : www.mysite.com/username, I should get that user's result accordingly. 我想要的是 :当我使用www.mysite.com/username搜索用户名时,应该相应地获得该用户的结果。 How can I rewrite the url for this? 我该如何重写网址? Please help! 请帮忙! Please feel free for any details. 请随时了解任何细节。

我想知道为什么您尝试使用.HTACCESS进行Ajax调用,无论哪种方式, http ://httpd.apache.org/docs/2.0/misc/rewriteguide.html都是最佳位置:)

Please try this plugin it can be useful. 请尝试使用此插件,它会很有用。 jquery.address jquery.address

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM