我有这样的网站树
controller (文件夹)
file1.php
file2.php
.
file10.php
view (文件夹)home.php
profile.php
message.php
login.php
register.php
.
index.phpcss.cssjs.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,那么我的URL应该是
www.mysite.com/john/profile/正如我所知道的:转到文件夹john,然后是profile,最后是index.php
我是否必须为每个用户制作每个文件夹和文件,还是有任何方法可以使用当前的站点树来完成它?
我希望你能理解我想说的话:
谢谢
发布于 2013-05-23 08:27:27
您需要使用一个.htaccess文件来创建漂亮的urls: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]https://stackoverflow.com/questions/16709020
复制相似问题