.htaccess 所有链接重定向到localhost/dashboard/ with codeigniter

ymzxtsji  于 2023-04-07  发布在  其他
关注(0)|答案(3)|浏览(126)

我对codeigniter非常陌生。我有一个codeigniter项目,我需要做一些更改。我已经将其粘贴到htdocs中,并将application/config/config.php的base_url更改为localhost的路径。
并更改了application/config/database.php中的数据库连接
经过以上修改后,我的索引页在localhost上打开得很好。2但是所有来自索引页的链接都重定向到http://localhost/dashboard/
我没有改变.htaccess文件内容。这里是:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

如何解决这个问题?

5lwkijsr

5lwkijsr1#

如果您需要删除index.php,请使用此

RewriteEngine on

RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
pcww981p

pcww981p2#

RewriteEngine on
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/$1 [L]

试试这个

piztneat

piztneat3#

我得到了同样的问题,并解决了做以下。如果你使用codeigniter 4
转到app/config/app.php文件,

public $indexPage = 'index.php';

将上述行替换为

public $indexPage = '';

相关问题