Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess将查询显示为路径_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess将查询显示为路径

.htaccess将查询显示为路径,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我知道这个问题在这里已经被问过很多次了。我无法解决这个问题,这是我的“最后手段”。 我已经尝试了我在这里遇到的每一个解决方案,我访问了至少10个网站(甚至尝试了.htaccess生成器),但我就是做不好。 我想重写url以将查询字符串显示为路径。 而不是显示: tricethebeast.com/post3.php?post_title=微妙地%20Spring 我想使用: tricethebeast.com/post3/Subtly Spring 我不太关心标题中的空格。如果需要

我知道这个问题在这里已经被问过很多次了。我无法解决这个问题,这是我的“最后手段”。
我已经尝试了我在这里遇到的每一个解决方案,我访问了至少10个网站(甚至尝试了.htaccess生成器),但我就是做不好。

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

而不是显示:
tricethebeast.com/post3.php?post_title=微妙地%20Spring

我想使用:
tricethebeast.com/post3/Subtly Spring

我不太关心标题中的空格。如果需要,可以将其更改为其他字符,并且在显示时可以单独处理。

此外,我希望能够处理反向外部请求:
tricethebeast.com/post3/Subtly Spring

并将其发送到“真实”位置:
tricethebeast.com/post3.php?post_title=微妙地%20Spring


*编辑:我应该提到我所说的“不起作用”的意思。由于一些语法错误或页面加载,我收到了500个错误,但是url没有改变(不正确的.htaccess)

试试看:

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

.htaccess
不能很好地处理错误,并且很容易出错,您需要完美地完成工作才能成功。有很多指南可以帮助你实现目标。你不需要在这里问一个新的SO问题。请阅读以下指南:,,一个非常好的,巨大的信息资源,等等…可能重复我使用的微妙的Spring作为例子。我希望能够处理动态标题。修改答案后,我有:RewriteRule^post/([\w-]+)$/post3.php上的RewriteEngine?post_title=$1[L]