URL重写一个ID与一个字符串变量重写、字符串、变量、URL

2023-09-02 09:38:41 作者:边城的梦

试图找出如何重写这个网址客户方

trying to figure out how to rewrite this url clientside

blog.com/post/how-to-get-the-ladies

要指向的服务器端,以

blog.com/post.php?id=123

我知道如何做到这一点:

i know how to do this:

blog.com/post/123

RewriteRule ^([^/]+)/?$ post.php?id=$1 [NC,L]

但你如何更换ID字符串文章标题塞?

but how do you replace the id string with the post title slug?

推荐答案

在网络服务器本身并没有对此加以区分,不能从你的独特文本标识的数据库ID转换。因此,一个htaccess的规则,由Web服务器单独评估不会帮助你。但它是如何做到在所有的网络应用程序?通常这种翻译是通过的Joomla /字preSS本身完成,它只能只要在how_to_get_the_ladies文本是已知的和独特的整个系统/数据库。

The webserver itself doesn't make this distinction and cannot translate from your "unique text identifier" to the database id. Therefore a .htaccess rule alone evaluated by the webserver will not help you. But how is it done on all those web-applications? Normally this translation is done by Joomla/Wordpress itself and it only works as long the "how_to_get_the_ladies" text is known and unique throughout the system/database.