路由使用的.htaccess的php查询

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

我想找到一个更好的解决方案来解决这个问题。我没有使用像硅石任何框架,Yii的等等。因此我没有被这些框架提供的通用路由处理机制。我的URL模式像

I am trying to find a better solution to solve the issue. I am not using any framework like silex, Yii etc. Thus i do not have the general routing handling mechanism provided by these frameworks. My url patterns are like

routing.php routing.php?action=create routing.php?action=list&id=1

和产生的URL我想有是

and the resulting url i want to have are

/routing /routing/create /routing/list/1

我的.htaccess一些非常基本的了解,下面是我目前书院

i have some very basic understanding of .htaccess, below is my current foundings

RewriteEngine On RewriteBase /name/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php

这些codeS很好地把所有的.php到/某事。但是我是一个stucked继续生成获取/ 路由/创建和 /路由/列表/ 1 。鸭preciate任何帮助。

These codes work well to put any .php to /something. However i am a stucked to continue to generate a general solution for getting /routing/create and /routing/list/1 . Appreciate for any helps.

推荐答案

有你的.htaccess这样的:

Have your .htaccess like this:

RewriteEngine On RewriteBase /name/ RewriteCond %{DOCUMENT_ROOT}/name/$1.php -f RewriteRule ^([^/]+)/([^/]+)/?$ $.php1?action=$2 [L,NC,QSA] RewriteCond %{DOCUMENT_ROOT}/name/$1.php -f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?action=$2&id=$3 [L,NC,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [L]

更多推荐

路由使用的.htaccess的php查询

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

发布评论

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

>www.elefans.com

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