Welcome Guest, Not a member yet? Register   Sign In
Setting up .htaccess
#1

[eluser]RockerBoy402[/eluser]
Okay, I'm trying to access my stylesheets, but I'm having a problem. Here is my folder layout:

-/var/www/
--/application
--/system
--/public_html
----/css
------style.css
----.htaccess
----index.php

As you can see my application and system folders exist outside the site root. If I go to http://mydomain.com/css/style.css I get a 404 Error. I know I need to set up .htaccess, but I'm not quite sure how. None of the examples/instructions I could find online were geared toward this setup.

Would someone be able to help me out with the proper .htaccess Mod_Rewrite rules? Also, my config.php file still has $config['index.php'] set to index.php...Some of the tutorials I found said I should set that to an empty string. If I need to do that, please let me know.

Thanks in advanced guys!

~RB
#2

[eluser]steelaz[/eluser]
Try temporary removing .htaccess file. When it's removed, does 404 error go away?

Post your .htaccess file contents.
#3

[eluser]RockerBoy402[/eluser]
My .htaccess file is empty. I've also tried adding in:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

That didn't help the problem, though. Not sure what to try at this point. The 404 Error I'm getting is a CI error and not the typical Apache 404 error.
#4

[eluser]RockerBoy402[/eluser]
Thank you Kindari on IRC for the solution:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
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>
#5

[eluser]InsiteFX[/eluser]
in your index.php file:
Code:
/**
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same  directory
* as this file.
*
*/
    $system_path = '../system';

    // or
    $system_path = './system';

/**
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server.  If
* you do, use a full server path. For more info please see the user guide:
* http://ellislab.com/codeigniter/user-guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
*/
    $application_folder = '../application';

    // or
    $application_folder = './application';

One of those should work for you.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB