I was wondering what caused my sub-domain to get 500 error. I guess it is due to my .htaccess file. I cannot access my sub-domain at all. The main directory is working fine. Only the sub-domains.
This is my .htaccess code
php_value auto_prepend_file none
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
I fixed it by adding .htaccess file using the same code
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
Related
I uploaded a cakePHP project to the Godaddy server.
I have also seen this link. But not solve the error:-
500 internal server error occured in CakePHP 3?
How to solve cakephp 500 Internal Server Error?
CakePHP 500 Internal Server Error
CakePHP shows 500 Internal Server Error
My .htaccess code in /root/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
In /root/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
In /root/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This error is still coming after a lot of effort.
Please Help?
It may not be a problem everytime. Your .htaccess code may be alright. Please check permission of your root folder on godaddy server. It dependent on which type of server you use. Please enable to your folder permission on server. Then it may be working for you.
My Laravel project is already inside in shared hosting server(i know what do you thinking...). And inside root folder i got a .htaccess file which has this code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
RewriteCond $1 !^(public)
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
This gives me good URL's without "public" but there is one case:
If i go:
www.example.com
so it always stays with URL www.....If i go:
https://www.example.com
it always stays with URL https://....
My question:
How to make that the URL would always be https://www.example.com whatever I enter www or https first?
This should do:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
You can do that by putting following lines in the .htaccess files
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^.*$ https://%{HTTP_HOST}/public%{REQUEST_URI} [L,R=301]
</IfModule>
Put the code in .htacces in your laravel root directory, it should do the job:
RewriteEngine On
# enforce https
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
# use public directory as root, but don't include it in url
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
Im using an MVC framework for my PHP application which works great. I have the below code in a .htaccess file in the root folder of my application. This redirects everything to the public folder which is causing issues for me. I want to apply the below to everyfolder apart from one. How would I go about doing this? ie. need to access the /dompdf/ directory and all subdirectories normally wihtout the below rule which redirects.
#<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
# </IfModule>
I think if I understand what you want, this should help -
#<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^dompdf [L,NC]
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
# </IfModule>
Replace your existing code with this one:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule (?!^(dompdf|public)/)^.*$ public%{REQUEST_URI} [L,NC]
Negative lookahead will prevent application of these rules for paths dompdf and public.
I have the following directory tree in public_html folder:
/app
/test
/cake
...
/app if the Application folder for my site and /test is a subdomain.
The problem is that I've changed the .htaccess, my site is working but the subdomain is returning a 500 error.
My .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Thanks.
Try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain.com$
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain.com$
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Add the RewriteCond below to prevent an infinite internal redirect, which could result in a 500 error
#skip processing existing files e.g css. png etc
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^$ app/webroot/ [L]
#if not already /app/webroot to prevent infinite internal redirect
RewriteCond %{REQUEST_URI} !^/app/webroot/ [NC]
RewriteRule (.*) app/webroot/$1 [L]
500 error usually means something is wrong with the code, like a missing ; in your model, view or controller. Try double-checking that?
How can I combine the .htaccess rules for CakePHP
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
with the following
RewriteEngine On
RewriteCond %{HTTP_HOST} folder.yoursite.com
RewriteRule ^(.*)$ /folder [L]
in other words redirect anything to app/webroot/ except /blog (which is an existing folder with a WordPress installation) and redirect blog.domain.com to the blog subfolder.
It should work automatically (at least with CakePHP 1.3), it's working for me...
My .htaccess looks like this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
You should also have a proper .htaccess in your wordpress (or any other application) folder that's not a part of the CakePHP application.