I have been tasked to migrate an old project running on aws to vps based cpanel, I have done the following:
- setup to cpanel to accept (only) php 5.6 & it's extensions, also setup exported db & it's credentials to required file.
- the path to the project is setup directly on the
public_html/
folder - the .htaccess file has been configured following :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^$ app/webroot/ [L]
</IfModule>
which i took from the cakephp installation documentation & added some - Link
The original project htaccess was a bit different however :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteCond %{SERVER_PORT} 80
php_value max_input_vars 100000
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
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 (.*) app/webroot/$1 [L]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
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://example.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
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 ^$ app/webroot/ [L]
</IfModule>
& removing the htaccess or not using it at all in both projects produces same error
Warning (2): scandir(../View/Ipac): failed to open dir: No such file or directory [APP/Config/routes.php, line 32]
Warning (2): scandir() [function.scandir]: (errno 2): No such file or directory [APP/Config/routes.php, line 32]
Warning (2): Invalid argument supplied for foreach() [APP/Config/routes.php, line 32]
I have tried to use the same htaccess in the new migration along with every other rule which 'seems' okay to me but it shows me internal server error. Now I am stuck here
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. Does anyone know how can I fix this. Any help is appreciated.
Okay, turns out that after 2 days of losing my mind on this, the issue was due to the htaccess set incorrectly in the
app/webroot
(which I missed) & also it's index file had a file permission of775
, which cpanel doesn't allow to be viewed publicly, setting those correctly booted the project up perfectly.