Mod rewrite 雪豹,修改,代码点火器

Mod rewrite 雪豹,修改,代码点火器,mod-rewrite,codeigniter,Mod Rewrite,Codeigniter,伙计们,我在《雪豹》里遇到了各种各样的麻烦。有人知道关于雪豹和mod_rewrite的文章吗?或者是一个简单的分步指南。我想做的是设置codeigniter,使URL看起来“漂亮” 所以 将成为 localhost/~myusername/ci_app/mycontroller/myaction 谢谢试试这个规则: RewriteEngine on RewriteBase /~myusername/ci_app/ RewriteRule ^[^/]+/[^/]+$ index.php/$0 [

伙计们,我在《雪豹》里遇到了各种各样的麻烦。有人知道关于雪豹和mod_rewrite的文章吗?或者是一个简单的分步指南。我想做的是设置codeigniter,使URL看起来“漂亮”

所以

将成为

localhost/~myusername/ci_app/mycontroller/myaction
谢谢

试试这个规则:

RewriteEngine on
RewriteBase /~myusername/ci_app/
RewriteRule ^[^/]+/[^/]+$ index.php/$0 [L]
根据,您应该使用:

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

“各种各样的麻烦”?请多说。您使用的是.htaccess文件还是Apache配置文件?(如果可以避免的话,不要使用.htaccess文件,它们更难,而且有点问题。)这个.htaccess文件在哪里?在我的用户站点文件夹(localhost/~myuser)中?或者实际的serverDocument文件夹(localhost)?@dotty:我想你应该把它放在你的
/Users/myusername/Sites/ci_app/
目录中。这很有效(在我添加了行选项+FollowSymlinks之后)但是有什么我不能加载css/style.css的吗?@dotty:你可能只是错误地引用了你的资源,因为像
css/style.css
这样的相对URL路径是从你当前文档的URL路径解析出来的。因此,在您请求
/~myusername/ci_app/index.php/mycontroller/myaction
的情况下,基本URL路径就是该URL路径。而
css/style.css
将解析为
/~myusername/ci_app/index.php/mycontroller/css/style.css
,而不是您可能认为的
/~myusername/ci_app/css/style.css
。因此,请使用绝对URL路径
/~myusername/ci_app/css/style.css
引用该资源或更改基本URL(请参见基本HTML元素)。
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]