Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何设置url中显示的默认路径_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何设置url中显示的默认路径

Javascript 如何设置url中显示的默认路径,javascript,jquery,html,Javascript,Jquery,Html,如何更改网站上的url路径 例如,当您开发网页时,您的地址如下: www.example.com/index.html www.example.com/about_us.html www.example.com/en/index.html 如何使这成为唯一的 www.example.com 在你访问的每一页上。。。 但是,当您转到下一个文件夹时,它只需要显示文件夹名称,而不需要显示页面名称,例如: www.example.com/en/ 是否已经为此编写了脚本?这将只能通过ajax调用来实

如何更改网站上的url路径

例如,当您开发网页时,您的地址如下:

www.example.com/index.html
www.example.com/about_us.html
www.example.com/en/index.html
如何使这成为唯一的

www.example.com
在你访问的每一页上。。。 但是,当您转到下一个文件夹时,它只需要显示文件夹名称,而不需要显示页面名称,例如:

www.example.com/en/

是否已经为此编写了脚本?

这将只能通过ajax调用来实现

例如,如果我点击主页按钮

$('.home').click(function(){
$.get('ajax/test.html', function(data) {
  $('.maincontainer').html(data); //populate the main container with the html of the other file

});
})
这将保留正在更改的url表单, 缺点是

1-如果我想给一些人你的主页链接,那么我不能

2-谷歌将无法抓取你的网站

现在,当他点击更改语言(en)时,我

然后,我将在根文件夹中创建一个目录,然后当他单击该目录时,用户将被重定向到与上面相同的文件夹


或者,为了避免代码重复,我将使其显示为get请求,如果设置了get变量,那么您可以将数据源切换到适当的文件

您的意思是
url重写
?是的,您也可以这样说