• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URL Rewrite rules

#1
[eluser]macleodjb[/eluser]
I'm having some trouble with the rewrite rules.

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

Code:
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.

#2
[eluser]Dyllon[/eluser]
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.

#3
[eluser]macleodjb[/eluser]
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

#4
[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:

Code:
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".

Code:
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.

#5
[eluser]macleodjb[/eluser]
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
www.example.com/index.php/register

#6
[eluser]macleodjb[/eluser]
take a look at the attached file to see my folder structure. This is my root folder.

#7
[eluser]macleodjb[/eluser]
if anyone else has this problem....

see this post

Codeigniter post

#8
[eluser]Draft[/eluser]
Hello.

I need a help.
How can I write RewriteRule for changing utl from:
http://website.com?a=1&b=2&c=3
to
http://website.com/a/1/b/2/c/3

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

Thankyou


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.