Home  >  Article  >  Backend Development  >  一个比较简单的问题

一个比较简单的问题

WBOY
WBOYOriginal
2016-06-23 14:05:53844browse

看到一个网站
http://www.*****.com/
登陆进去后,网址栏上显示
http://www.*****.com/user
想问一下,它是用的哪一个文件显示的,刚刚接触php.

谢谢。


回复讨论(解决方案)

index.php 部分

if(user_is_login_in){
   header("location:dirname(__FILE__).'/user.php"); //如果用户已登录,跳转到user.php
}else{
   //主代码
}

.htacess 部分


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/ $1.php [L,QSA] 
#去掉.php后缀名 http://www.*****.com/user.php 定向为 http://www.*****.com/user

index.php 部分

if(user_is_login_in){
   header("location:dirname(__FILE__).'/user.php"); //如果用户已登录,跳转到user.php
}else{
   //主代码
}

.htacess 部分


RewriteEn……
补充一下,user也有可能是个目录

user 是个目录

用户经过验证后,执行 echo tiaos("/user/");

有一个函数
function tiaos($url){
$key="<script>location.replace('".$url."');</script>";
return  $key;
}

也有可能是MVC架构,user控制器

好几种方法能做到。
1. 自己弄个简单跳转
2. URL Rewrite
3. framework

看到一个网站
http://www.*****.com/
登陆进去后,网址栏上显示
http://www.*****.com/user
想问一下,它是用的哪一个文件显示的,刚刚接触php.

谢谢。 一般情况下的话,是登陆成功后, 在验证登陆成功的function中会有跳转到http://www.*****.com/user,用到的php函数可能是header()。

index.php

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn