.htaccess将查询显示为路径

时间:2016-06-19 17:56:35

标签: .htaccess mod-rewrite

我知道这个问题在这里被多次询问和回答。我无法解决这个问题,这代表了最后的手段'为了我。
我已经尝试了我在这里遇到的所有解决方案,并且我访问过至少10个网站(甚至尝试过.htaccess生成器),我无法做到正确。

我想重写我的url以将查询字符串显示为路径。

而不是显示:
tricethebeast.com/post3.php?post_title=Subtly%20Spring
我想用:
tricethebeast.com/post3/Subtly-Spring
我并不十分关注标题中的空间。如果需要,可以将其更改为不同的字符,我可以在显示时单独处理。

此外,我希望能够处理反向外部请求:
tricethebeast.com/post3/Subtly-Spring
并将其路由到真实的'地点:
tricethebeast.com/post3.php?post_title=Subtly%20Spring

*编辑:我应该提到我的意思是什么不起作用。我因为一些语法错误或页面加载而得到500个错误但是url只是没有改变(不正确的.htaccess)。

1 个答案:

答案 0 :(得分:0)

尝试一下:

RewriteEngine On
RewriteRule ^post3/Subtly-Spring$ /post3.php?post_title=Subtly\%20Spring [L]