Codeigniter shows views differently when index is removed


Tags: css,codeigniter,routing

Problem :

I'm working in Codeigniter and Apache with a virtual host set up and have have added a .htaccess file to the rout directory (next to the index.php) with the following code

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

My view file is in another location outseide of the route and I have updated the index.php file to reflect this as below.

$system_path = '../CI/system';
$application_folder = '../CI/application';
$view_folder = '../CI/views';

If I access my website using the following addess it renders perfectly

localhost/tsh/public_html/index.php/home/index

However if I use any of the following it renders without applying any css etc.

localhost/tsh/public_html/home/index
localhost/tsh/public_html/home
localhost/tsh/public_html

Is anyone able to suggest why this is and how I can get around it? I've searched around but been unable to find any suggestions.



Solution :

Go to config/routs.php

Change this

$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Path - config/config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

in your XAAMP Control Panel.

Go to->Config->php.ini

Replace this

allow_url_include=on

in .htacess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

to avoid css loading error.

<link href="<?php echo base_url(); ?>folder/css/style.css" rel="stylesheet" type="text/css" media="all"/>

    CSS Howto..

    How to get html data-attribute value in css regular expressions

    CSS How to add content under fixed position navbar [closed]

    How to print outlines and background colors from css, when using JQuery printElement, and IE8?

    How do you override CSS applied by jQuery UI theme properly?

    How to combine css selectors

    I can't figure out how to get display property to work when it comes to multiple div elements

    CSS How to align checkbox image

    How do you make these div elements display correctly?

    How to make a barlike chart but only with html and css [closed]

    how to calculate css rules priority in Javascript?

    How to change transparency of background image using javascript?

    How specify two css classes: from property and conditional class

    How to use very large font sizes in Internet Explorer with CSS that won't affect design?

    How to adjust height based on content css

    How to center video source in circle shape using css, html

    how to use variables when setting CSS properties in Jquery?

    how to make a CSS animation end point the right edge of the browser

    How to center parts of a list efficiently with CSS [Img Inside]

    CSS only: how to make a div the width of its biggest row, with children as inline-blocks?

    How do I use this CSS animation in my HTML file?

    How to show hidden button with css media query?

    how to add same width on bootstrap dropdown menu item as parent item

    How to fix header cannot sticky in wordpress?

    How to DRY Sass code using variables?

    How to link to a “tab” on my website

    How to create a CSS style which override another CSS style

    How to style the first row of every tr group?

    How to force elements to stay in the same row

    How to fill video element with poster image even if the poster image is a different aspect ratio than its video element? [duplicate]

    Showcase Image and Carousel Caption