3

I want to create a app url 'http://example.com'. But entering the url, it shows 'HTTP Error 403.14 - Forbidden'. when i have inserted 'index.php' at the last of url like 'http://example.com/index.php' the landing page is rendering in the browser I have changed the

$config['base_url'] = 'http://example.com';

$config['index_page'] = '';

and

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

in config.php file. Then i have placed the .htaccess file in the codeigniter root folder along with application and system folder. Then in the .htaccess file i have coded with

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

I just want to remove the 'index.php' from the url. I am using IIS 8.5 web server.

anand
  • 1,559
  • 5
  • 21
  • 45
  • Sorry that i can't give you an exact answer due to not having any experience with IIS. But there are several answers listed here. And the second answer worked for me. http://stackoverflow.com/questions/1445385/how-to-remove-index-php-in-codeigniters-path?lq=1 One more thing you might try though is editing the .htaccess a bit more "RewriteEngine on RewriteBase / RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L]" – Martin Jan 29 '16 at 08:23
  • I already that way, but didn't work. Does apache and iis works in the same way – anand Jan 29 '16 at 08:26
  • Seems not: http://stackoverflow.com/questions/25439087/how-to-remove-index-php-in-codeigniter-on-windows-server-and-iis Try this then. It actually seems that you will also need URL Rewrite module and the spec (conf) will look different from apache. – Martin Jan 29 '16 at 08:28
  • What version of CI you using? –  Jan 29 '16 at 08:31
  • I edited the .htaccess with your code "RewriteEngine on RewriteBase / RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L]" and o/p is the same "HTTP Error 403.14 - Forbidden" – anand Jan 29 '16 at 08:31
  • My codeigniter version - 3.0.4 latest version and iis version - 8.5 – anand Jan 29 '16 at 08:31
  • I have some htaccess here you can try https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter make sure in main directory your htaccess file. –  Jan 29 '16 at 08:32
  • replace below line RewriteRule .* index.php/$0 [PT,L] and check it – msvairam Jan 29 '16 at 08:36
  • IIS does not use taccess so it's no use for him. These resources will help your cause: http://stackoverflow.com/questions/9965124/how-to-rewrite-the-index-php-of-codeigniter-on-windows-azure http://stackoverflow.com/questions/25439087/how-to-remove-index-php-in-codeigniter-on-windows-server-and-iis – Martin Jan 29 '16 at 08:38
  • You can also check this [post](http://stackoverflow.com/questions/19183311/codeigniter-removing-index-php-from-url) – Skaranjit Jan 29 '16 at 10:09
  • if i am using apache web server your(Skaranjit) post will be helpful but i am using iis – anand Jan 29 '16 at 10:17
  • htaccess file RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] my site is working http://demo.crowdfundingscript.com/ config file $config['uri_protocol'] = 'AUTO'; $config['index_page'] = ''; – Rockers Technology Jan 29 '16 at 11:57
  • Do i have to change something in the index.php in the root folder – anand Jan 29 '16 at 13:14
  • I am approaching the same issue... Using Code Igniter 3.1.7 with IIS 8.0 :( , I tried different customized rules provided from yall's htaccess and imported to we webconfig using URL Write but still not working. Any help would be appreciated – Dip Mar 13 '18 at 20:49

3 Answers3

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

  my site is working http://demo.crowdfundingscript.com/ 
  config file
  $config['uri_protocol']   = 'AUTO';
   $config['index_page'] = '';
0

Replace this line:-

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

also change your base url as below.

$config['base_url']    = 'http://'.$_SERVER['HTTP_HOST'].'/';

Write your rules as below:

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

Hope it will work for you :)

Ravi Hirani
  • 6,511
  • 1
  • 27
  • 42
0

In config.php,

remove index.php in $config['index_page']

For ex :

$config['index_page'] = '';

teshvenk
  • 403
  • 3
  • 8