简体   繁体   中英

Internal Server Error 500 on Code Igniter running on centos in Google Cloud

I'm running a CI based web application that runs fine on its old server but I'm migrating it to a centos 7/cwp instance on google cloud.

After i set it up how i normally setup CI, im getting HTTP 500 and Internal Server Errors.

I'm suspecting its got to do with the .htacess but i cant figure out whats wrong. Any help is appreciated!

Its running CWP on centos 7 on a google cloud instance. Things i have done:

  1. enabled mod_rewrite
  2. installed php-mysqli
  3. edited php.ini for mysql and mysqli extensions
  4. made a new .htaccess
  5. can't seem to see any error in the apache logs

Below is my current .htaccess file from the old server:

# 301 Redirect URLs.
Redirect 301 /www.example.com/example/about-us https://www.example.com/home/pages/about-us

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

//RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
//RewriteRule . index.php
RewriteCond %{HTTPS} off
//RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9] {32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

<Files 403.shtml>
order allow,deny
allow from all
</Files>

RewriteCond %{HTTP_HOST} ^\*\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.\*\.example\.com$
//RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.example\.com" [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com$
//RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
//RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.example\.com\/" [R=301,L]

When i used the above .htaccess (with // the old cpanel modrewrites, i get internal server error message), when i delete the .htaccess or replace the .htaccess with other or standard CI .htaccess, i just get HTTP 500 error.

with // the old cpanel modrewrites, i get internal server error message

You can't use // to comment out config lines in .htaccess - that certainly explains your immediate 500 error. You need to use # , as shown on the first line of your config file.

 //RewriteRule . index.php 

You shouldn't be commenting out this line - without this CI will not be able to route your URLs.

when i delete the .htaccess or replace the .htaccess with other or standard CI .htaccess, i just get HTTP 500 error.

That is quite possibly a different question, so we would need to see the precise .htaccess file you are using.

Btw, "internal server error" and "HTTP 500 error" are the same thing - you seem to be implying they are different?

As noted in comments, you should check your server's error log for the specifics of this error.

 RewriteCond %{HTTP_HOST} ^\\*\\.example\\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\\.\\*\\.example\\.com$ //RewriteCond %{REQUEST_URI} !^/\\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$ //RewriteCond %{REQUEST_URI} !^/\\.well-known/pki-validation/(?:\\ Ballot169)? //RewriteCond %{REQUEST_URI} !^/\\.well-known/pki-validation/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$ RewriteRule ^/?$ "https\\:\\/\\/www\\.example\\.com" [R=301,L] 

What is this supposed to be doing? (It doesn't do anything in its current state.)

 RewriteCond %{HTTP_HOST} ^example.com$ //RewriteCond %{REQUEST_URI} !^/\\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$ //RewriteCond %{REQUEST_URI} !^/\\.well-known/pki-validation/(?:\\ Ballot169)? //RewriteCond %{REQUEST_URI} !^/\\.well-known/pki-validation/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$ RewriteRule ^/?$ "https\\:\\/\\/www\\.example\\.com\\/" [R=301,L] 

This only canonicalises requests for the document root. It won't do anything for any other URLs. However, it's also in the wrong place in the config file and probably isn't doing anything anyway. It needs to go at the top of the file, before the CI front-controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM