Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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/8/mysql/59.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
Php 正在重新编写URL_Php_Mysql_Html_.htaccess - Fatal编程技术网

Php 正在重新编写URL

Php 正在重新编写URL,php,mysql,html,.htaccess,Php,Mysql,Html,.htaccess,当我为我拥有的网站上的给定条目单击评论部分时,URL如下所示: http://www...com/.../comments/index.php?submission=Portugal%20Crushes%20North%20Korea&submissionid=62&url=nytimes.com/2010/06/22/sports/soccer/22portugalgame.html?hpw&countcomments=3&submittor=johnjohn1

当我为我拥有的网站上的给定条目单击评论部分时,URL如下所示:

http://www...com/.../comments/index.php?submission=Portugal%20Crushes%20North%20Korea&submissionid=62&url=nytimes.com/2010/06/22/sports/soccer/22portugalgame.html?hpw&countcomments=3&submittor=johnjohn12&submissiondate=2010-06-21%2019:00:07&dispurl=nytimes.com
我如何让它看起来像下面的URL

http://www...com/.../comments/Portugal-Crushes-North-Korea-62
提前感谢,


约翰

你想看看这个:

你以前从来没有做过。我发现它非常有用

您可能需要这样的内容(在根目录的.htaccess文件中):

我会用

而不是


工作起来会更容易。

谢谢。。。这个链接是一个很好的介绍。我有两个问题:在我想出了一些有效的重写规则之后,我会去更改站点中的所有超链接,使它们链接到URL的干净版本吗?另外,我注意到您的示例没有我使用GET方法传递的所有信息。。。干净版本的URL是否需要在混乱版本的URL中包含所有的信息/变量?我只是作为一个简单的例子来做的。如果你愿意,你可以把它们放进去。但是如果你使用id在页面上获取信息,url也会出现,那么我不会这么认为。如果答案正确,你应该勾选这个答案。我很肯定它回答了你的问题。
RewriteEngine On
RewriteRule ^comments/([a-z0-9_]+)/([0-9]+)?$ index.php?submission=$1&submissionid=$2 [L]