Amir Hossein
Amir Hossein

Reputation: 35

My url doesn't work with / in codeigniter

In Codeigniter URL , I remove index.php
in Config.php:

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

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

url: http://localhost/code/test it's work
But this url : http://localhost/code/test/ doesn't work!
And this : http://localhost/code/test/name doesn't work!

Upvotes: 0

Views: 150

Answers (3)

Tharanga
Tharanga

Reputation: 57

change as below

in config.php

$config['base_url'] = '/appname/'; $config['index_page'] = '';

in .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /appname/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

This should work

Upvotes: 1

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

Use this .htaccess

# -FrontPage-

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And in application/config/conifg.php add these

$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';

Upvotes: 1

Prakash
Prakash

Reputation: 335

Step 1: Check if your .htaccess is in your root directory.

Step 2: replace the code in the .htaccess with this

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

No need of the IfModule tags

Step 3: Go to application->config->config.php, find and replace these ones,

$config['index_page'] = '';

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

Step 4: Restart your server.

Upvotes: 2

Related Questions