我将我的文件夹设为public_html / vote
这是服务器的默认行为
http://mydomain.com/~voteimbo/ <===the public_html folder
http://mydomain.com/~voteimbo/vote/ <==== the vote folder in public_html
问题是,如果我尝试在route.php中进行路由,除非我在我的网址中添加index.php,否则显示404(服务器404,而不是codeigniter)
e.g. $route["test"] = front_end/index
http://mydomain.com/~voteimbo/vote/index.php/test <==== work
http://mydomain.com/~voteimbo/vote/test <==== 404
这是我的设置
的config.php
$config['base_url'] = 'http://mydomain.com/~voteimbo/vote/';
$config['index_page'] = '';
route.php
$route['default_controller'] = "front_end/check_date";
$route['404_override'] = '';
$route['test'] = "front_end/index";
htaccess的
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
感谢您的帮助
更新:
在这里尝试了这种方法:
CodeIgniter removing index.php not working
但输出是
Array
(
)
所以我想知道这是什么问题?感谢
答案 0 :(得分:1)
好的,假设(如你所说)你的codeigniter设置存储在目录/vote/
中。
你应该可以在htaccess文件中执行类似的操作,以便能够在没有index.php
RewriteEngine on
RewriteBase /vote/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]