Moving From Development to Live Site breaks CSS - html

Using CodeIgnitor to manange this site I have configured the css in the following location:
{link rel="stylesheet" type="text/css" href="<? echo base_url();?>application/assets/css/public.css" />
Firebug shows me that the link points exactly where it should, unfortunately,
The problem is I keep getting 403 errors when it tries to load it.
my .htaccess file looks like this, and by the way, I don't really know what I'm looking at here:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|application/assets/js|application/assets/css|application/assets/images)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
RewriteCond $1 ^(images|js|css)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./public/$1 [L,QSA]
How do I get this CSS to load?
Additional Info:
In that the assets folder there is also a js folder and an images folder and the favicon is NOT being pulled from that images folder either.

It sounds like the configuration on that folder and/or the server are refusing you access to read the file.
http://en.wikipedia.org/wiki/HTTP_403
Try navigating directly to the css file and you can easily confirm that you are getting a 403 error, if so it is to do with permissions.
Try accessing your development site remotely rather than from the same machine and you may see the same error there.

Related

Remove .html extension in url

Today I tried to remove html file extension from my website, for example:
example.com/page.html to example.com/page
I watched some tutorials, but nothing seems to work...
I created .htaccess file in root directory
Copied code (also tried different ones):
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
It didn't work when I opened my website as file, with Live Server (VS Code extension) or actual website (hosted on Replit)
Any idea, why it doesn't work? Any help appreciated...
See whole repository
Edit: Someone said, I have to remove .html file extension. I get error that the file is not found
Yo should do it in this way:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC, L]
SOLVED
As someone said, .htaccess file doesn't work on Replit. I've done following:
Made folder for every .html file
Moved that file inside of the folder I made
Renamed the file to index.html

Image url being treated as a page request in yii2

I am working on a project which is developed in Yii2. Today I came across a weird and funny issue of image url being treated as a page request.
When I try accessing image with url as https://www.websitename.com/images/image1.jpg, it shows me the image. And when I try accessing image with url as https://www.websitename.com/images/image1-lockdown.jpg then it shows 404 Error. On checking I found that internally the request was changed to "/site/images/image1.jpg". As we all know to access images no controller call is made.
Same issue was generated on local machine (Ubuntu 16.04). Just added "lockdown" into the name of image url.
I am using Yii2 Advanced Template. OS: For production CentOS and for development Ubuntu 16.04.
Note: I couldn't verify if the same issue exists for windows or not.
Kindly Help!
Edited: .htacess (root folder on production)
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule admin(.+)?$ /backend/web/$1 [L,PT]
RewriteRule gamer/(.+)?$ /gamer/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ /frontend/web/$1 [L]
</IfModule>
.htaccess (frontend/web on production)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

Make domain folder act as root

I have a domain for example https://test.com this domain contain a full project in https://test.com/system.
Problem:
Whenever I write <link ref="stylesheets" href="/style/main.css"> it search in the domain root not in the system directory which the project in.
What I have tried to do:
I have tried to edit all my path to be equal to href="style/main.css" instead of href="/style/main.css".
This solution works but I won't do this every time I go in production mode.
What I am trying to do:
I know there is a solution using .htaccess but I don't know how to write it..
Try
<link ref="stylesheets" href="./system/style/main.css">
or
<link ref="stylesheets" href="../system/style/main.css">.
If it still won't work, use three dots.
<link ref="stylesheets" href=".../system/style/main.css">.
It has worked for me.
To set a subdirectory as root with .htaccess
It will depend, with some hosting services you only need to add this line:
RewriteBase /system
If that doesn't works for you, try this:
RewriteEngine On
# Map http://www.example.com to /system.
RewriteRule ^$ /system/ [L]
# Map http://www.example.com/x to /system/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/system/
RewriteRule ^(.*)$ /system/$1
# Add trailing slash to directories within system
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^system/(.*[^/])$ http://www.example.com/$1/ [R=301]

rewrite everything except files and directories

i want to create a .htaccess rewriting rule for everything except existing files or folders, but cannot figure out what the problem seems to be.
My Code now is this.
RewriteEngine on
RewriteCond %{REQUEST_URI} !(-f|-d)$
RewriteRule .* index.html
i dont want to create a rule for everything except the allready existing files and folders in case i create aything else on the server.
the rewriting works properly but the exeptions do not.
the right code for this need is
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f #exeption for files
RewriteCond %{REQUEST_FILENAME} !-d #exeption for dirs
RewriteRule .* index.html

modrewrite to remove the file extension but still load the page

I have a subdomain with .php pages in it. I just want to remove the .php I have written some code gathered from other posts on stack, so far I have this
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} (\.php(.*)\sHTTP/1)
RewriteRule ^(.+)\.php$ /$1 [R=301,L,QSA]
this rewrites
subdomain.example.com/weddings.php
to
subdomain.example.com/weddings
However it also creates a 404 page not found error. Am I doing something wrong?
Solved it. anyone struggling with the same thing here is my solution
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
found it on
http://css-tricks.com/snippets/htaccess/remove-file-extention-from-urls/
a fantastic website.