Php 管理网页和URL
我有一个这样的网站树Php 管理网页和URL,php,url-rewriting,Php,Url Rewriting,我有一个这样的网站树 控制器(文件夹) file1.phpfile2.php…file10.php 查看(文件夹) home.phpprofile.phpmessage.phplogin.phpregister.php index.php css.css js.js 目前,index.php是很常见的,它包含了用户想要的页面 www.mysite.com/?show=profile 首先,我要验证变量show,并在index.php index.php $show=$_GET['show'
控制器
(文件夹)
file1.phpfile2.php
…
file10.php
查看
(文件夹)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);
但是我不希望我的URL像这样www.mysite.com/?show=profile
相反,我希望如果用户john
点击页面profile
,那么我的URL应该是
www.mysite.com/john/profile/
据我所知,上面写着:进入文件夹john
,然后是profile
,最后是index.php
我是否必须为每个用户创建每个文件夹和文件,或者是否有任何方法可以使用当前的站点树来完成它 我希望你明白我想说的话:(
Thanx您需要使用.htaccess文件来创建漂亮的URL: 编辑:我的看起来像这样:
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]
哦,是的,我听说了:D,但我不知道如何使用它,thanx我将阅读你的教程:)请我添加了我自己的htaccess(希望它有帮助)。对不起:-p@Quentin很高兴在这里再次见到你:)