【发布时间】:2015-03-31 05:47:30
【问题描述】:
我对 codeigniter 有一点问题,我有一个 .htaccess 用于重写 index.php,如果我把我的项目放在 /var/www 上或者我为它创建一个虚拟主机,它会很好用。
但我想使用我的用户目录,例如http://localhost/~userdir/myproject。如果我在尝试向控制器发出请求时使用我的用户目录,例如:http://localhost/~userdir/myproject/signup,我会收到此错误:
没有找到
在此服务器上找不到请求的 URL /index.php。
这是我当前的配置:
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
application/config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['encryption_key'] = 'myencryption_key';
//all remaining is the default config
此配置在http://localhost/ 以及具有http://example.com/ 之类的域但不适用于我的用户目录http://localhost/~userdir/project/ 的生产环境中效果很好
我做错了什么?有什么想法吗? 提前致谢。
【问题讨论】:
标签: php apache .htaccess codeigniter mod-rewrite