我有一个像这样的网站树
controller
(文件夹)
file1.php
file2.php
.....
file10.php
view
(文件夹)
home.php
profile.php
message.php
的login.php
register.php
.....
index.php
css.css
js.js
目前index.php
很常见,它包含用户想要的页面
www.mysite.com/?show=profile
首先,我要验证变量show
,并在index.php
的index.php
$show=$_GET['show'].".php";
include("view/".$show);
但是我不希望我的网址像www.mysite.com/?show=profile
这样,我希望如果用户john
点击页面profile
,那么我的网址应为
www.mysite.com/john/profile/
正如我所知道的那样:转到文件夹john
然后转到profile
,最后转到index.php
我是否必须为每个用户制作每个文件夹和文件,或者有什么办法可以使用现有的网站树来完成它?
我希望你理解我想说的话:(
感谢名单
答案 0 :(得分:1)
您需要使用.htaccess文件来创建漂亮的网址:http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/
编辑:我看起来像这样:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(css|js|jpg|jpeg|png|gif|ico|swf)$
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+) index.php?params=$1&%{QUERY_STRING} [L]