.htaccess CentOS中的Codeigniter mod重写
我正在尝试在Apache/2.0.52(CentOS)服务器上设置我的项目(内置Codeigniter) 在我的本地XAMPP服务器上,一切都可以正常工作,但在live服务器上,当我尝试访问myproject.com/agents等页面时,它显示了这一点 '在此服务器上找不到请求的URL/home/virtual/site777/somefolder/var/www/html/index.php/agents' 我现在的重写规则是:.htaccess CentOS中的Codeigniter mod重写,.htaccess,codeigniter,centos,.htaccess,Codeigniter,Centos,我正在尝试在Apache/2.0.52(CentOS)服务器上设置我的项目(内置Codeigniter) 在我的本地XAMPP服务器上,一切都可以正常工作,但在live服务器上,当我尝试访问myproject.com/agents等页面时,它显示了这一点 '在此服务器上找不到请求的URL/home/virtual/site777/somefolder/var/www/html/index.php/agents' 我现在的重写规则是: RewriteEngine on RewriteCond $
RewriteEngine on
RewriteCond $1 !^(assets|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我的application/config.php文件中有以下设置
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
如果有人能帮助我,我将不胜感激
谢谢大家! 您必须启用apache的url重写模块。在我的CentOS上,我只有以下功能:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteRule ^(.*)$ index.php/$1 [L]
但我的网站位于/var/www/html
。我绝对不是Apache方面的专家,但也许您需要设置
RewriteBase /home/virtual/site777/somefolder/var/www/html/
同样感谢大家观看并回答我的问题
我能够在htaccess文件中使用RewriteBase解决我的问题。只是想澄清一下,
/home/virtual/site777/somefolder/var/www/html/
是在httpd.conf
中指定的目录。如果您只是在该目录中放置一个testindex.html
,您可以访问该目录吗?@danneth上述目录是在httpd.conf中指定的。访问索引页时没有问题。我的问题是访问上面提到的其他页面。我甚至可以使用index.php/agents结构访问这些页面,但当我从url中删除index.php时无法访问。在我的localhost中,它工作得非常好