Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在获得干净的 URL 工作时,我一直很糟糕。
如何编写 RewriteRule 以转换以下干净的 URL
/posts/test-title.php
从
post-slug.php?slug=test-title
谢谢。
RewriteEngine On Options +FollowSymlinks RewriteBase / RewriteRule ^posts/(.*) /post-slug.php?slug=$1
不确定您是否打算在漂亮的 URL 上添加 .php 扩展名.. 似乎是多余的-如果这样做,那么您可以删除 post-slug.php 中的扩展名
$slug_with_ext = str_replace(".php", "", $slug);