views:

420

answers:

2

hay guys, i'm having all sorts of mod_rewirte trouble in snow leopard. Anyone know any decent articles focused on snow leopard and mod_rewrite? Or perhaps a simple step by step guide. What i want to do is setup codeigniter so the urls looks 'pretty'.

so

localhost/~myusername/ci_app/index.php/mycontroller/myaction

would become

localhost/~myusername/ci_app/mycontroller/myaction

thanks

+1  A: 

Try this rule:

RewriteEngine on
RewriteBase /~myusername/ci_app/
RewriteRule ^[^/]+/[^/]+$ index.php/$0 [L]
Gumbo
where does this .htaccess file live? in my users Sites folder (localhost/~myuser)? or the actually serverDocument folder(localhost)?
dotty
@dotty: I thought that you want to put it in your `/Users/myusername/Sites/ci_app/` directory.
Gumbo
This works (after i added the line Options +FollowSymlinks)However anything i cant load css/style.css any ideas?
dotty
@dotty: You’re probably just referencing your resources wrongly since relative URL paths like `css/style.css` are resolved from the URL path of your current document. So in the case you’re requesting `/~myusername/ci_app/index.php/mycontroller/myaction` the base URL path is exactly that URL path. And `css/style.css` would be resolved to `/~myusername/ci_app/index.php/mycontroller/css/style.css` and not `/~myusername/ci_app/css/style.css` as you may think. So use the absolute URL path `/~myusername/ci_app/css/style.css` to reference that resource or change the base URL (see BASE HTML element).
Gumbo
+1  A: 

Per CodeIgniter documentation, you should use:

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