PHP GET方法没有的index.php?ID = XXX [英] PHP GET Method without index.php?id=XXX

查看:135
本文介绍了PHP GET方法没有的index.php?ID = XXX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了(在 PHP PDO )的链接收缩,与 GET 方法(index.php文件ID = 1?)但我想它是这样的: domain.com/ [ ID]

I have written (in PHP and PDO) a link shrinker that works with the GET method (index.php?id=1) but I want it like this: domain.com/[ID].

推荐答案

在你的主文件夹中创建.htaccess文件,并写入文件中的内容如下

create .htaccess file in your main folder and write the below content inside the file

RewriteEngine On

RewriteRule ^([a-zA-Z0-9-/]+)$ index.php?id=$1 [L]

结果

domain.com/1 = domain.com/index.php?id=1

domain.com/1 = domain.com/index.php?id=1

domain.com/home = domain.com/index.php?id=home

domain.com/home = domain.com/index.php?id=home

domain.com/ID = domain.com/index.php?id=ID

domain.com/ID = domain.com/index.php?id=ID

这篇关于PHP GET方法没有的index.php?ID = XXX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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