在没有https的情况下编写URL删除斜杠

时间:2016-10-26 15:50:31

标签: php .htaccess codeigniter

如果我这样写url: https://subdomain.domain.net/directory/ 但是,如果我尝试直接在浏览器中写入:subdomain.domain.net/directory/浏览器修剪第一个斜杠,因此无法加载页面,网址如下所示:subdomain.domain.netdirecotry

我正在使用codeigniter,并在我的.htaccess中使用它:

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

1 个答案:

答案 0 :(得分:0)

首先,这些日子里CI3你的HTACCESS应该是:

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

你的config.php中可能有一些错误,请务必使用尾部斜杠正确设置base_url:

$config['base_url'] = 'http://ci.app/';

并删除index.php:

$config['index_page'] = '';

应该是它。

相关问题