How do I get mod_rewrite to work on Heroku?

I am trying to rewrite the url using the following rule:

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

and this is the .htaccess file I created:

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

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

thanks

+1
php apache .htaccess mod-rewrite heroku
source share
2 answers

I think the main problem is that you rewrite the rule

try something like:

 <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^([^/]+) index.php?id=$1 [L] </IfModule> 
+1
source share

If you downloaded mod_rewrite and your rules are in the htaccess file at the root of your document. The rules you have cause an endless loop. You need to add a condition or two to prevent this:

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

or

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

All Articles