htaccess的路由PHP

编程入门 行业动态 更新时间:2024-10-04 21:23:24
本文介绍了htaccess的路由PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想写htaccess的一些简单的路由PHP

I am trying to write some simple routing in htaccess for PHP

我的文件看起来像这样现在:

My file looks like this for now:

RewriteEngine On RewriteBase /webservices/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ server.php [QSA,L]

但不起任何作用。

But it does nothing.

这是我想与htaccess的事情是,所有的来电server.php被抓住这样的:

The thing that I want with htaccess is that all the calls to server.php are caught like this:

localhost:8888/webservices/server.php?username=test&password=test

写入

localhost:8888/webservices/server/u/test/p/test/

有人可以帮助我吗?

Can someone help me with that?

推荐答案

这是实际工作,因为它重定向所有查询 server.php 。因此,

It is actually working, because it redirects all queries to server.php. Therefore

localhost:8888/webservices/server/u/test/p/test/

可以通过 server.php 进行处理,在那里你可以轻易地捕获使用URI的部分爆炸()在 $ _ SERVER [REQUEST_URI] 阵列。忘记

can be handled by server.php, where you can easily catch parts of the URI using explode() on the $_SERVER["REQUEST_URI"] array. Forget the

localhost:8888/webservices/server.php?username=test&password=test

URL结构,你将不再需要它了,因为使用了的.htaccess 你刚写的,你可以动态地处理每一个请求到服务器上的 server.php 。

URL structure, you won't need it anymore, because using the .htaccess you've just written, you can dynamically handle every request to your server on server.php.

[QSA] 在的.htaccess 追加查询字符串的URI,这是不需要的,因为我们想摆脱它,对吗?既然你不会使用这种格式,你可以删除 QSA 标记。

[QSA] in your .htaccess appends query string to the URI, which is not needed, because we want to get rid of it, right? Since you wont use that format, you can remove QSA flag.

更多推荐

htaccess的路由PHP

本文发布于:2023-11-02 06:35:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551633.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   htaccess   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!