Welcome Guest, Not a member yet? Register   Sign In
URL Rewrite rules

I'm having some trouble with the rewrite rules.

I copied this right out of the user manual and it doesn't work properly

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

It works on the main index page, but my css gets lost somewhere.

If i try to add a controller like www.example.com/register it doesn't work at all and shows the main index.php page.

If i try to call the controller direct like www.example.com/index.php/register it calls the controller but again my css doesn't load.

Any suggestions? This implementation is becoming very tiresome.

Where is your css located in the file structure?
My guess is you are either referencing it incorrectly or you need to add an exception to your RewriteCond.

my css is located outside my system folder in the root directory contained in a folder that named css. That's only half my problem the other half is that whenever i place rewrite statements my sub controllers don't work

[eluser]Phil Sturgeon[/eluser]
Please search the forums for questions like this as the same problem has been answered so many times.

You need to add any static content into your rewrite condition like this:

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

or use a more dynamic solution like the following code, which will say "if it is not an existing file or directory, plese route via index.php".

Options +FollowSymLinks
    RewriteEngine on

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

In this one (a mini version of the code I use) you will notice the leading slash has been removed from index.php. This means it will always stay relative to the location of the .htaccess file which could solve the problem with your "sub-controllers" not loading correctly.

I don't know what my malfunction is. I've tried everything suggested to me and it still does not work.

I have a controller called register.php

i should be able to access it like www.example.com/register

Correct or no?

even with the rewrite you suggest i can only access it like this

take a look at the attached file to see my folder structure. This is my root folder.

if anyone else has this problem....

see this post

Codeigniter post


I need a help.
How can I write RewriteRule for changing utl from:

and problem in that I don't really know a count of variables.


Theme © iAndrew 2016 - Forum software by © MyBB