内部服务器错误:.htaccess中的mod_rewrite出现问题


Internal Server Error: Having trouble with mod_rewrite in .htaccess

我的URL是这样的:

http://example.com/Folder/index.php?city=Berlin&id=1

我想把它变成:

http://example.com/Berlin/1

使用Generate It!我得到这个代码:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /Folder/index.php?city=$1&id=$2 [L]

但是,当在我的.htaccess文件中添加它并尝试打开http://example.com/Berlin/1时,我得到了以下错误:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at example.com Port 80

我做错了什么?从小时开始,我一直在努力让它发挥作用,但没有成功。

我找到了解决方案:

我在我的.htaccess:中使用这个

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/id/([^/]*)$ /Folder/index.php?city=$1&title=$2&id=$3 [L]

要更改此链接:

http://example.com/Folder/index.php?id=566&city=Berlin&title=this_is_the_websites_title

至:

http://example.com/Berlin/this_is_the_websites_title/id/566