PHP都开始使用mod_rewrite的参数 [英] PHP all GET parameters with mod_rewrite

查看:103
本文介绍了PHP都开始使用mod_rewrite的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我设计我的应用程序。我应该让接下来的事情就。全部搞定参数(?VAR =值)mod_rewrite的帮助应该变换到/ var /值。我怎样才能做到这一点?我只有1 PHP文件(的index.php),因为我usign了的FrontController模式。你能帮助我这个mod_rewrite规则?_爱对不起,我的英语水平。谢谢你在前进。



I am designing my application. And I should make the next things. All GET parameters (?var=value) with help of mod_rewrite should be transform to the /var/value. How can I do this? I have only 1 .php file (index.php), because I am usign the FrontController pattern. Can you help me with this mod_rewrite rules?

Sorry for my english. Thank you in advance.

推荐答案

我做这样的事情上使用搜索引擎友好的URL地址的网站。

I do something like this on sites that use 'seo-friendly' URLs.

在.htaccess:

In .htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]

然后在index.php文件:

Then on index.php:

if ($_SERVER['REQUEST_URI']=="/home") {
    include ("home.php");
}

本的.htaccess规则告诉它加载的index.php,如果该文件或目录的要求没有被发现。然后你只需解析请求的URI来决定的index.php应该做的。

The .htaccess rule tells it to load index.php if the file or directory asked for was not found. Then you just parse the request URI to decide what index.php should do.

这篇关于PHP都开始使用mod_rewrite的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆