简体   繁体   English

URL重写Codeigniter htaccess

[英]URL-rewriting Codeigniter htaccess

Since I changed a website to another server, I have a problem that I can't access the website on domain.com/codeigniter/ . 由于我将网站更改为另一台服务器,因此我遇到了无法访问domain.com/codeigniter/上的网站的问题。 My default controller is info/ It worked with http://www.domain.com/codeigniter/info/ and http://www.domain.com/codeigniter/info/model/ 我的默认控制器是info /。它与http://www.domain.com/codeigniter/info/http://www.domain.com/codeigniter/info/model/一起使用

$route['default_controller'] = "info/";
$route['404_override'] = '';
$route['info/(:any)'] = "info/view/$1";

.htaccess 的.htaccess

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

But on the new server it doesn't work. 但是在新服务器上它不起作用。 The problem is that it always ends in http://www.domain.com/index.php and not the index.php of the directory of the codeigniter installation.. 问题在于它总是以http://www.domain.com/index.php结尾,而不是codeigniter安装目录的index.php结尾。

What could be the problem? 可能是什么问题呢?

there are a few things that make CodeIgniter work in secondary folder: first of all, you must change $config['base_url'] = http://www.domain.com/codeigniter/'; 使CodeIgniter在辅助文件夹中起作用的原因有很多:首先,必须更改$config['base_url'] = http://www.domain.com/codeigniter/'; in application/config/config.php . application / config / config.php中

Then, of course, change .htacces file to this: 然后,当然,将.htacces文件更改为此:

 <IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # block hidden directories
  RewriteRule "(^|/)\." - [F]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

Php mod_rewrite module is needed. PHP mod_rewrite模块是必需的。

After changing the .htacces and leaving the 'base_url' empty ( http://www.domain.com/codeigniter/ doesn't work). 更改.htacces并将“ base_url”留空后( http://www.domain.com/codeigniter/不起作用)。

I have the following problems: 我有以下问题:

http://www.domain.com/codeigniter/ --> ERROR 404 from CI
http://www.domain.com/codeigniter/info/ --> No input file specified
http://www.domain.com/codeigniter/index.php/info/ --> OK

EDIT: Problem solved.. I forgot a ? 编辑:问题解决了..我忘记了? after the index.php in the .htaccess & I changed the default controller in routes.php to info/view/home/ 在.htaccess中的index.php之后,我将route.php中的默认控制器更改为info / view / home /

It was a combination of multiple things... It is strange that it worked on the old hosting. 它是多种事物的结合...奇怪的是,它可以在旧主机上工作。 It was obviously wrong.. 显然是错误的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM