我有一个网站,并且在子文件夹(test
(下安装了CodeIgniter 2 site
用户可以使用以下链接访问网站:
http://www.example.com/test/
当用户要使用上面的链接访问(test
(网站时,URL重定向到下面的链接,并显示下面的错误。
http://www.example.com/test/login
未找到
在此服务器上找不到请求的URL/test/login。
然后我将index.php
添加到上面的URL,显示登录页面。
http://www.example.com/test/index.php/login
当我再次提交我的用户名和密码时,URL重定向到,没有登录。
http://www.example.com/test/login
再说一遍,没有找到。
.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
config.php
:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = "AUTO" ;
我试过$config['base_url'] = "http://www.example.com/test"
,但仍然不起作用。
在config/config.php
中
$config['base_url'] = 'https://stackoverflow.com/';
$config['index_page'] = '';
在.htaccess(放置在应用程序文件夹之外(中
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
将.htaccess替换为以下代码
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
在.htaccess 中尝试此操作
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]