2
votes

I am trying to remove "index.php" from my URL content of my htaccess file is below

 RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /qasim/outlets/index.php/$1 [L]

working URL
localhost/qasim/outlets/index.php/items_controller/

Error on
localhost/qasim/outlets/items_controller/

is there any way to get rid of index.php :)

my config.php file content file is below:

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


$config['base_url'] = '';


$config['index_page'] = '';


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

$config['url_suffix'] = '';


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


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


$config['enable_hooks'] = FALSE;



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


$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'; // experimental not currently in use

$config['log_threshold'] = 0;

$config['log_path'] = '';

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

$config['cache_path'] = '';


$config['encryption_key'] = 'abc';


$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;


$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']      = "/";
$config['cookie_secure']    = 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['compress_output'] = FALSE;


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


/
$config['rewrite_short_tags'] = FALSE;


$config['proxy_ips'] = '';

after all alterations my configuration file is now looking like it but its not working

1
You are accessing it via localhost not by domain..that may be a problem in rewrite. Please tell me which is your OS and webserver?Harikrishnan
i am using win7, xampp and framework on which i ma working is codeigniter.Qasim Khokhar
not working is there any other setting to do with xampp because i am playing with .htaccess for first time ?Qasim Khokhar
Oohhhhhhhhhh Thanks its done my .htaccess file was place inside the application folder that was the problem. :)Qasim Khokhar

1 Answers

1
votes

In config.php add following replaces

$config['index_page'] = "index.php" to $config['index_page'] = ""

replace $config['uri_protocol'] ="AUTO" by $config['uri_protocol'] = "REQUEST_URI"

In .htaccess

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

Edit for hosting site under a domain in XAMPP

Edit C:\Windows\System32\drivers\etc\hosts (Drag and drop that file to notepad) Add this line at the end of file 127.0.0.1 www.test.com

Edit Fullpath\XAMPP\apache\conf\extra\httpd-vhosts.conf

Add these code at the end

NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "Fullpath/xampp/htdocs/Projectname" ServerName test.com ServerAlias www.test.com </VirtualHost>

Make sure to replace the Fullpath with your exact path. restart apache restart your browser and type www.test.com

You can see your project & then check rewrites.