简体   繁体   中英

.htaccess not working with IP address in codeigniter

I am Using Codeigniter 3.1.2.my url looks like http://20.186.5.144/myproject/controller .folder path is var/www/html/myProject/

The problem is that index.php is not being removed from route.

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

The above is .htaccess configuration. What am I doing wrong?

Set your base url in config.php

/*
|--------------------------------------------------------------------------
| 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/';

When on live domain don't for get to change it to your domain example:

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

If not set you will run in to some link errors when trying to load css and images etc.

Some more htaccess https://github.com/wolfgang1983/htaccess_for_codeigniter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM