【问题标题】:.htaccess not working with IP address in codeigniter.htaccess 不能在 codeigniter 中使用 IP 地址
【发布时间】:2017-09-09 05:41:20
【问题描述】:

我正在使用 Codeigniter 3.1.2.my url 看起来像 http://20.186.5.144/myproject/controller.folder 路径是 var/www/html/myProject/

问题是index.php 没有从路由中删除。

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

以上是.htaccess的配置。我做错了什么?

【问题讨论】:

  • 你也可以试试this回答

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

在 config.php 中设置你的基本 url

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/

$config['base_url'] = 'http://localhost/myproject/';

当使用实时域时,不要将其更改为您的域示例:

$config['base_url'] = 'http://www.example.com/';

如果未设置,则在尝试加载 CSS 和图像等时会遇到一些链接错误。

更多 htaccess https://github.com/wolfgang1983/htaccess_for_codeigniter

【讨论】:

    猜你喜欢
    • 2016-10-18
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-01
    • 2014-02-05
    • 2014-08-07
    • 2014-03-09
    相关资源
    最近更新 更多