从http://localhost/我想访问http://localhost/1.php
我怎样才能使它,所以我可以访问1.php文件在浏览器中不改变url?
在.htaccess
文件中使用DirectoryIndex 1.php
您可以使用AJAX获取不同PHP文件的内容并将其显示在您的登陆页面
下面是一个简单的例子:index . html页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Ajax example</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script src="https://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("#page1").click(function(){
$('#result').load('page1.html');
});
$("#page2").click(function(){
$('#result').load('page2.html');
});
//and so on
});
</script>
</head>
<body>
<ul>
<li><a id="page1" href="#">One</a></li>
<li><a id="page2" href="#">Two</a></li>
<li><a id="page3" href="#">Three</a></li>
</ul>
<div id="result" style="clear:both;">
</div>
</body>
</html>
假设页面1.html的内容为
<h1>Hi this is page1</h1>
点击链接"one"将用page1.html等内容填充div
在这种类型的实现中,您应该为其他页面设置不带header和meta的页面