如何从GoDaddy子文件夹中的CodeIgniter站点中删除index.php?

如何从GoDaddy子文件夹中的CodeIgniter站点中删除index.php?

问题描述:

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!

我需要知道我在config.php文件和 .htaccess中需要做什么 code>文件,以便能够从我的CodeIgniter站点中删除 index.php code>路径,该站点安装在子文件夹中,如下所示: p>

jeanpaulruizvallejo.com/proyectos/pruebas/ci-rest-api / code> p>

现在我可以像这样打开URL: p>

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

...但它应该像: nn

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

nn

关于如何获取的任何想法 解决这个问题? p>

先谢谢你的帮助! p> div>

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"] = "";

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]