我想写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:
http://localhost:8888/webservices/server.php?username=test&password=test
写入
http://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
http://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
http://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.