我如何获得的mod_rewrite工作在Heroku? [英] How do I get mod_rewrite working on Heroku?

查看:95
本文介绍了我如何获得的mod_rewrite工作在Heroku?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用下面的规则来重写网址:

I'm trying to rewrite a URL using the following rule:

RewriteRule ^([^/]*)$ /curation.php?id=$1 [L]

这是我创建一个.htaccess文件:

and this is an .htaccess file I created:

 RewriteEngine On
 RewriteRule ^([^/]*)$ /curation.php?id=$1 [L]

但是当我把它给我的Heroku的服务器,我得到的所有网页上的一个500内部服务器错误。我究竟做错了什么?

but when I push it to my Heroku server, I get a 500 Internal Server Error on all pages. What am I doing wrong?

感谢

推荐答案

如果你的mod_rewrite加载,和你的规则是在您的文档根目录的htaccess文件。你有这些规则导致一个无限循环。你需要一个或两个条件添加到prevent是:

If you have mod_rewrite loaded, and your rules are in an htaccess file in your document root. The rules that you have are causing an infinite loop. You need to add a condition or two to prevent that:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/curation\.php
RewriteRule ^([^/]*)$ /curation.php?id=$1 [L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /curation.php?id=$1 [L]

这篇关于我如何获得的mod_rewrite工作在Heroku?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆