URL缩短PHP [英] URL Shortener PHP
本文介绍了URL缩短PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在找创建一个URL缩短,虽然我遇到,我不认为通过的问题。
我需要的用户能够找到他的ID,使用斜线GET请求( /
)而不是 =
例如,
I'm looking to create a URL Shortener, although I'm encountering an issue which I cannot think through.
I need the user to be able to find his id with a get request using a slash(/
) instead of a ?=
for example,
而不是使用 oli.pw?id=100
我需要它是 oli.pw/100
Instead of using oli.pw?id=100
I would need it to be oli.pw/100
.
我看着URL重写,但老实说,我不知道如何做到这一点的所有get请求。
I looked into URL rewriting but I honestly have no idea how to accomplish this with all get requests.
如果这不够详细发表评论如下。谢谢!
If this is not detailed enough leave a comment below. Thanks!
推荐答案
您的意思是?
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /(index\.php)?\?id=([0-9]+)([^\ ]*)
RewriteRule ^ /%3?%4 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/?$ /?id=$1 [L,QSA]
这篇关于URL缩短PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文