Welcome Guest, Not a member yet? Register   Sign In
htaccess Help
#1

[eluser]Unknown[/eluser]
Hello all

Can somebody please help with the following htaccess problem.

I have an assets folder containing subdirectories for css, js, and image files that is located in the same folder as index.php. These files are referenced by a number of view files.
I also have some css and js files that apply to a particular view. These are located in the same folder as the view. (my views are organised in subdirectories within the view folder).

What I want to be able to do is have

<link href="assets/css/main.css" rel="stylesheet" type="text/css" />
<link href="thisfile.css" rel="stylesheet" type="text/css" />

as well as having htaccess rules that eliminate the need for index.php in the url address.

Any assistance on this will be gratefully received.
#2

[eluser]jedd[/eluser]
Hi ajackson001 - an interesting question you have there, mostly because you've written it without using a question mark anywhere! Wink

Perhaps you could show us what you've done so far.

It seems like you have declined to read the user guide at all, specifically the [url="/user_guide/general/urls.html"]URL section[/url] which provides an .htaccess file ready to go.

The [url="/wiki/FAQ"]FAQ[/url] has some pointers about removing index.php, plus there's about 27,000 existing threads in the forums with lots of information on how to do this too.
#3

[eluser]Unknown[/eluser]
Hello

My apologies for not being clearer on this.

My htaccess file is as follows
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]

which n0xie came back with on one of my earlier posts.

My view file has the following content
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="assets/css/main.css" rel="stylesheet" type="text/css" />
<link href="file.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="div1">Hello</div>
<div id="div2">Goodbye</div>
<img class="logo" src="/assets/images/logo.png" />


main.css has
body {
margin: 0px;
padding: 0px;
background-color:#FFFFCC;
}

#div1{
font-weight: bold;
font-size:26px;
color: red;
}

and file.css has
#div2 {
background-color: purple;
color: white;
height: 25px;
}

When I open the view I can see the image, the background color is correct and div1 is formatted as expected.
However the text in div2 is not formatted according to file.css. My guess is that this is because the htaccess file is looking for file.css in the assets folder.

The question therefore is what do I need to do to the htaccess file in order to get both the css in the assets folder applied, and the css in the same folder as the view applied?
#4

[eluser]jedd[/eluser]
I think the absolutely easiest and cleanest thing you could do is keep all your CSS files in the same place - under your ./assets/ directory, safe from the influence of CI.

I think you're inviting a whole lot of work, mess and confusion if you store CSS files around the place, especially if you're trying to pull them in using two different methods.
#5

[eluser]Jeroen Brussich[/eluser]
And maybe have a look a the Asset Helper for CodeIgniter?




Theme © iAndrew 2016 - Forum software by © MyBB