Cakephp CSS file not loading - .htaccess

I have a website working on one server. I am changing hosting, so I created a website on another server for testing.
Everything seems to be working, except CSS. It is not loading at all. I have 777 for tmp folder and mod re_write enabled.
I can see all cached files except for CSS.
Please advise and help
This is my .htacess file in www
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my second htaccess inside app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
This is my third htaccess inside webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
and the url is 23.236.49.24

Add this line:
RewriteBase /
under
RewriteEngine On
in the 3 .htaccess files

Create .htaccess file in webroot folder.
And paste this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

Related

CSS & JS file not loading in my cakphp appliaction

I have a cakephp website hosted on goDaddy, the css and js file are showing 404 error and the page appears blank.
i have done changes to .htaccess file in both webroot and main directory
.htaccess file in www directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
and .htaccess file in webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
i'm not sure what is the cause.I checked the error log and its shows this
2020-09-02 08:06:25 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Webroot could not be found.
Request URL: /webroot/
Try using this on the /webroot .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Force HTTPS in htaccess while also only making public folder accessible

This .htaccess file is in my /public_html/ folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
And this .htaccess is inside my /public_html/public/ folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
I need to add a rule like the following:
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
I get an issue with it redirecting too many times.
I need to still use the public folder as my root and the front controller inside /public/ but I want to direct all traffic to https.
Can someone help me understand how to go about this?
Do I need to change my rewrite rules pertaining to the /public/ folder?
Add http->https rule in .htaccess of /public_html/public/ folder as this one:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}/$0 [R=301,NE,L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Make sure to test in a new browser or completely clear browser cache.

CodeIgniter: Remove index.php redirects to the wrong folder

I tried all solutions I found about removing index.php from the URL, but I still cannot make it work properly.
Problem:
the URL http://localhost/rc/index.php/person/find shows the correct page.
the URL http://localhost/rc/person/find shows the WAMP main page (without any image) like it redirects to the root's parent folder.
my configuration:
I created .htaccess is placed in my root directory (/www/rc/.htaccess) which contains the following code:
<IfModule mod_rewrite.c>
# Turn on MOD REWRITE engine
RewriteEngine On
#Remove index.php from the URL
RewriteBase /rc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#Also tried the following lines without success
#RewriteRule .* index.php/$0 [PT,L]
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# If mod_rewrite is not installed, fire 404 error
ErrorDocument 404 /index.php
</IfModule>
I have also set $config['index_page'] = ''; (in www/rc/application/config/config.php file).
You must put your rule before CodeIgniter's main rule.
Replace your current code by this one (your htaccess has to be in rc folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rc/
RewriteCond %{THE_REQUEST} \s/rc/index\.php/([^\s]+) [NC]
RewriteRule . %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
The answer was given by Justin Iurman in the comment of the first answer:
Are you sure mod_rewrite is enabled ? You can check it in your apache config
This can be enabled in httpd.conf file or from the WAMP tray icon.

htaccess in codeigniter to clear index.php at url

I'm newbie with htacces..
I've file htaccess like this
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I called url like this without index.php it's work
http://localhost/url/
but when I try to call
http://localhost/url/controller/
and
http://localhost/url/controller/method/
the page back to xampp's home.
so what would I do? I want url without index.php.
thank you very much every advice.
Looks like you need something simple like:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|media|favicon\.ico|ipadicon\.jpg)
RewriteRule ^(.*)$ /index.php/$1

htaccess and cakephp - whats the correct path/to/app in this situation

I'm trying to install cakephp on a 1&1 account but running into problems.
I believe I need to add
RewriteBase /path/to/cake/app
to the htaccess file but I can't figure out what the path should be.
I have put the cakephp files in a folder called scissors on the most bottom level of folders I can browse to using filezilla. With that in mind I tried
RewriteBase /scissors/app
but that didn't work. What should it be?
EDIT:
I have managed to get the site to work (sort of) but unfortunately the css doesn't seem to get loaded.
The three htaccesses which I have which are working but not pulling the css are:
in /scissors
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /app
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
in scissors/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
in scissors/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Does anyone have any idea why this isn't correctly loading the css?
thanks
Answer is for cake 2.0 and I'm assuming that you've unzipped downloaded archive inside your public_html, so the path to cake looks like
/home/your_login/public_html/scissors/files_and_folders_unzipped_here
Or just
/public_html/scissors/files_and_folders_unzipped_here
as
/home/your_login
may not be visible.
Inside "scissors" folder (where app, lib, plugins, vendors etc folders are) place .htaccess with
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Inside "app" folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
And inside "webroot" folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
There is one more way to install cake (allows to have multiple sites on one "core config") but unzipping everything inside public folder is the easiest one.

Resources