I have a favicon file that won't show up on my site.
At first I thought it might be the htaccess that's to blame, but I'm not sure if that's the right direction.
My htaccess is set to send the URL to index.php for parsing:
#Pass to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|gif|jpe?g|png|txt|xml|js|pdf|html)$ /home/username/public_html/domain.com/index.php [NC,L]
#Hotlinking
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com(/)?.*$ [NC]
RewriteRule .*\.(gif|jpe?g|bmp|png|ico|css|js|pdf)$ http://domain.com [R,NC]
And I have the following HTML:
<link rel="icon" href="http://domain.com/favicon.ico" />
<link rel="shortcut icon" href="http://domain.com/favicon.ico" />
When I try to access the favicon.ico file directly, the image doesn't load at all. When I try opening the image file locally (from my hdd, using chrome or firefox) it opens and shows up fine.
Please see comments (above) for solution/workaround.
Related
My website is working fine.
All controllers works fine unless I put a slash at the end the pages broke.
Here is oringal URL: Saaf.Pk
But when I put a slash at the end, style & images broked: Here
I know the problem is that URL path got changed. But what's the general solution for this situation?
My .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
are you using base_url to define every image, js, css etc?
example img
<img src="<?=base_url('assets/uploads/cms/') . $cms->logo_2?>" alt="Logo">
example js
<script src="<?=base_url('assets/plugins/jquery-3.3.1/jquery.min.js')?>"></script>
example css
<link href="<?=base_url('assets/guide/css/hopscotch.css')?>" rel="stylesheet"/>
First of all, set the base_url in config folder config.php location in application->cofig->config.php and use as $config['base_url'] ='https://saaf.pk/';
Than give the link of images, css and js as ">
Don't forget to use the helper URL in autoload.php file.
I know this has been asked many times, and trust me that I've opened them all and following the steps but it still stuck for me. The css is also mess up (http://anakpanti.com/ab-cargo/)
I have CI project and it works in my localhost, but after I move it to webhosting the controller can't be found (except the default one).
The requested URL /ab-cargo/controllers_aboutus/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Here what have I done:
Change first letter controller class to capital
Change first letter filename controller to capital
Change.htaccess code into this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Change file config into:
$config['base_url'] = 'http://anakpanti.com/ab-cargo/';
$config['index_page'] = '';
That's all the steps.
Oh, I know the problem.
There should be 2 .htaccess files placed in the project.
First, in the root folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
And also inside the application folder:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
this is your baseurl right (http://anakpanti.com/ab-cargo/). S add rewiteBase /ab-cargo.
Use this .htaccess
RewriteEngine On
RewriteBase /ab-cargo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
When including style sheet in header use base_url() in href tag
<link rel="stylesheet" href="<?php echo base_url();?>CSS/main.css" type="text/css">
I was wondering if anyone could help? Basically I've got a set of mod_rewrite rules and they all work well except if I put a trailing slash at the end of the URL it goes crazy. Still show's the page (sometimes) except all of the CSS, JS, etc is not included because the path messes up when there's a trailing slash. The only way to solve it is to put a BASE tag which I would really like to avoid as it brings it's own set of issues. Is there something wrong with my htaccess? I just need it to ignore the trailing slashes.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^resetpassword/([^/.]+)/?$ resetPassword.php?resetCode=$1 [L]
RewriteRule ^activate/([^/.]+)/?$ activateAccount.php?ACTCode=$1 [L]
RewriteRule ^dashboard/?$ dashboard.php [NC,L]
RewriteRule ^login/?$ login.php [NC,L]
RewriteRule ^register/?$ register.php [NC,L]
RewriteRule ^messages/inbox/??$ messagesInbox.php [NC,L]
RewriteRule ^messages/archive/??$ messagesArchive.php [NC,L]
RewriteRule ^messages/??$ messagesInbox.php [NC,L]
There's likely not a good fix for this because you'll be switching "directory" levels in any case (like in messages/inbox).
The most common solution is to either use an absolute path to reference CSS, images etc.:
<link rel="stylesheet" href="/css/styles.css">
or to have a PHP variable containing the web root:
<link rel="stylesheet" href="<? echo $webroot; ?>/css/styles.css">
Both these approaches are vastly better than using a base tag, or doing some .htaccess-based redirection shenanigans.
Hello I have created a new subdomain of my domain and I am building a code igniter application. Everything is working OK except the fact that I cannot target the stylesheet or any other file in the application.
I have structure like this:
Root
/application
/css
/images
/js
/system
/userguide
Inside the css folder I have a style.css file.
I have tried to add this stylesheet to my application and it is not possible.
The strange thing is that even when I the url directly in the browser it sais that it cannot find the file.
I am on Bluehost, not sure if that has something to do with the configuration of the server or the configuration of the codeigniter.
Please help as I have tryied every possible method.
Thanks to all in advance!
Change your htaccess file to
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon \.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
This is standard which i have been using in my many CI Apps and it works fine :)
Also this htaccess file should be alongwith application, system folder(outside application folder)
Insert following line in your html file:
<link href="css/style.css" rel="stylesheet">
Double check that you have copied the file with correct name in css folder.
I assume that your other settings are correct.
At first it should be better to put images, css and js folders in a folder named "public" on the root.
Then you can use this code:
<LINK href= "<?=site_url(); ?>public/css/style.css" rel="stylesheet" type="text/css">
Another way you can include a css file is by using the template library.
If the problem insists then you may change your root .htaccess file like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
I have managed to resolve my own problems after reading the links that Jigar pointed me to.
My solution is to add in the htaccess file of the root:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
I downloaded MyClientBase application which is based on code igniter. After the installation, I looked at the MyClientBase's website but the index.php is still there by default.
I tried to remove the index.php using the tips in codeigniter's user guide but it doesn't work.
Is there any solution out there for this issue? Thank you
I use the following .htaccess file to remove index.php. I'm not sure which one the user guide specifies, but I found this to be working perfectly:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
Also remove 'index.php' from your config.php file. Good luck!
i don't know if it will help but, i use this to remove my index.php from codeigniter url, create a file named .htaccess and put it to your codeigniter folder.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]