【问题标题】:Internal Server Error: Having trouble with mod_rewrite in .htaccess内部服务器错误:.htaccess 中的 mod_rewrite 出现问题
【发布时间】:2016-07-22 22:24:57
【问题描述】:

我的网址是这样的:

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

我做错了什么?我从 几个小时 开始尝试让它工作,但没有成功。

【问题讨论】:

  • 重写规则 ^(.*)/(.*)$ /Folder/index.php?city=$1&id=$2 [L]
  • 不工作,仍然出现同样的错误。

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


【解决方案1】:

我找到了解决办法:

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

【讨论】:

    猜你喜欢
    • 2018-05-10
    • 2011-07-09
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 2014-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多