0

I am new to CodeIgniter. I have a simple project inside ayaz named ci_first2. when I write localhost/ayaz/ci_first2 in url then project is opened. enter image description here

But when I click on links then pages not opened and show error: enter image description here

But when I write localhost/ayaz/ci_first2/index.php, then every thing works fine. enter image description here

click on Home: enter image description here

click on Product: enter image description here

I used CodeIgniter 3.1.2: I want to eleminate index.php from url, and make it workful without it. help me friends , thanks in advance.

config.php:

Skylink
  • 83
  • 1
  • 9

1 Answers1

0

You have to add .htaccess file on root directory. Just make a new file of name .htaccess in your root directory(ci_first2).And put the following code....

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

.htaccss file is used for URL Rewriting.

change $config['index_page'] = '';present in application/config/config.php file

change $config['base_url']='http://localhost/ayaz/ci_first2';
Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19
  • Friend, this didn't work for me. I don't know why? . still when I type **localhost/ayaz/ci_first2**, and then click in Home, or Product, or About Us, it show me error: **The requested URL /ayaz/ci_first2/home was not found on this server.** – Skylink Dec 10 '16 at 03:35
  • did u set base_url of config.php? – Hikmat Sijapati Dec 10 '16 at 03:38
  • yes, I set base_url of config.php, that is: **$config['base_url'] = 'http://localhost/ayaz/ci_first2';**, but without it, also show error like above. – Skylink Dec 10 '16 at 03:49
  • you can reference from here..http://stackoverflow.com/questions/19183311/codeigniter-removing-index-php-from-url – Hikmat Sijapati Dec 10 '16 at 03:59