简体   繁体   中英

How can I remove the index.php from a CodeIgniter site on a subfolder in GoDaddy?

I need to know what do I have to do on the config.php file and in the .htaccess file in order to be able to remove the index.php path from my CodeIgniter site that is installed in a subfolder like this:

jeanpaulruizvallejo.com/proyectos/pruebas/ci-rest-api/

Right now I can open URL's like this one:

jeanpaulruizvallejo.com/proyectos/pruebas/ci-rest-api/index.php?blog/comments

... but it should be like:

jeanpaulruizvallejo.com/proyectos/pruebas/ci-rest-api/blog/comments

Any ideas on how to solve this?

Thanks in advance for your help!

In an htaccess file in the ci-rest-api folder add:

RewriteEngine On
RewriteBase /proyectos/pruebas/ci-rest-api/

RewriteCond %{THE_REQUEST} /ci-rest-api/index\.php\??([^\ ]*)
RewriteRule ^ %1? [L,R]

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

So, finally this is what worked for me, hope it helps somebody.

The .htaccess file:

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

The config.php file looks like this:

<?php
defined("BASEPATH") OR exit("No direct script access allowed");

$config["base_url"] = "http://jeanpaulruizvallejo.com/proyectos/pruebas/ci-rest-api/";

$config["index_page"] = "";

$config["uri_protocol"] = "QUERY_STRING";

$config["url_suffix"] = "";

$config["language"] = "english";

$config["charset"] = "UTF-8";

$config["enable_hooks"] = FALSE;

$config["subclass_prefix"] = "MY_";

$config["composer_autoload"] = FALSE;

$config["permitted_uri_chars"] = "a-z 0-9~%.:_\-";

$config["allow_get_array"] = TRUE;
$config["enable_query_strings"] = FALSE;
$config["controller_trigger"] = "c";
$config["function_trigger"] = "m";
$config["directory_trigger"] = "d";

$config["log_threshold"] = 0;

$config["log_path"] = "";

$config["log_file_extension"] = "";

$config["log_file_permissions"] = 0644;

$config["log_date_format"] = "Y-m-d H:i:s";

$config["error_views_path"] = "";

$config["cache_path"] = "";

$config["cache_query_string"] = FALSE;

$config["encryption_key"] = "";

$config["sess_driver"] = "files";
$config["sess_cookie_name"] = "ci_session";
$config["sess_expiration"] = 7200;
$config["sess_save_path"] = NULL;
$config["sess_match_ip"] = FALSE;
$config["sess_time_to_update"] = 300;
$config["sess_regenerate_destroy"] = FALSE;

$config["cookie_prefix"] = "";
$config["cookie_domain"] = "";
$config["cookie_path"] = "/";
$config["cookie_secure"] = FALSE;
$config["cookie_httponly"] = FALSE;

$config["standardize_newlines"] = FALSE;

$config["global_xss_filtering"] = FALSE;

$config["csrf_protection"] = FALSE;
$config["csrf_token_name"] = "csrf_test_name";
$config["csrf_cookie_name"] = "csrf_cookie_name";
$config["csrf_expire"] = 7200;
$config["csrf_regenerate"] = TRUE;
$config["csrf_exclude_uris"] = array();

$config["compress_output"] = FALSE;

$config["time_reference"] = "local";

$config["rewrite_short_tags"] = FALSE;

$config["proxy_ips"] = "";

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