0

My code is working fine on another server. I'm just moving host. Code is exactly the same. I just copied and pasted to new location.

with a blank htaccess file I do not give any errors. But if I type even a single line for example

RewriteEngine on

I get 500 error.

Here is whole htaccess file to be mentioned

RewriteEngine on


# Forcing HTTPS
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_METHOD} !^POST$

# hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=302,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/\.]+)/?$ profile.php?id=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ profile.php?id=$1&amount=$2 [L]

Options -Indexes

<FilesMatch "\.(?i:gif|jpe?g|png|ico|css|js|swf)$">

  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=1728000, public, must-revalidate"
  </IfModule>

</FilesMatch>
  • 2
    If you get a 500 response then you need to check your server's error log for details of the error. But if RewriteEngine on alone is triggering a 500 error then it would seem to suggest that mod_rewrite is not enabled? – DocRoot May 21 at 12:58
  • you might want to add some basic logs, loke the apache server logs, which modules your apache is build with and started with, your OS version. – Dennis Nolte May 21 at 12:58
  • DocRoot then how can I enable it? – robert hofer May 21 at 13:12
  • @roberthofer: Are you the admin on that machine? – Sven May 21 at 13:23
  • Apache mode rewrite was not enabled. Problem solved when I enabled it. Thanks guys. – robert hofer Jun 2 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.