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

时间:2016-07-22 22:24:57

标签: php apache .htaccess mod-rewrite internal-server-error

我的网址是这样的:

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

我做错了什么?我正在尝试小时以使其正常工作,但没有成功。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

我在.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