【问题标题】:.htaccess CodeIgniter.htaccess CodeIgniter
【发布时间】:2018-08-30 00:21:15
【问题描述】:

我在项目中遇到 htaccess 问题,当我在 locale 上使用 htaccess 时,它运行良好并且没有问题,但是当我将它上传到服务器时,它就不起作用了。

我希望我的 index.php 消失,我的域是 sindanasih-server.com/receiving。 接收是我的项目的名称。

我的htaccess是这样的。

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

我的配置是这样的

$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
$newurl = str_replace("index.php","", $_SERVER['SCRIPT_NAME']);
$config['base_url']    = "$http" . $_SERVER['SERVER_NAME'] . "" . $newurl;

$config['index_page'] = '';

$config['uri_protocol'] = 'REQUEST_URI';

当我打开 sindangasih-server.com/receiving out 这样的文字。

在此服务器上找不到请求的 URL /receiving/tiket/tampildatatiket。

【问题讨论】:

标签: php .htaccess codeigniter


【解决方案1】:

尝试对base_url 使用以下配置:

$newurl = str_replace( basename( $_SERVER['SCRIPT_NAME'] ), "", $_SERVER['SCRIPT_NAME'] );
$config['base_url']    = "$http" . $_SERVER['HTTP_HOST'] . "" . $newurl;

【讨论】:

    猜你喜欢
    • 2012-05-16
    • 2023-03-29
    • 1970-01-01
    • 2014-03-08
    • 2011-03-18
    • 2012-09-10
    • 2020-12-08
    • 2016-01-05
    • 2012-11-10
    相关资源
    最近更新 更多