3

I have tried with following code.

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

I have replaced with blank in config file index_page but still not working and getting this error.

404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Please help me to sort out this.

Shalu
  • 291
  • 1
  • 2
  • 11
  • What version of codeigniter you using and what operating system? –  Jun 30 '15 at 07:52
  • I am using 2.2 and windows 7. All is working fine on previous server but when i moved on new server then this problem is coming. – Shalu Jun 30 '15 at 07:59
  • 1
    This may help https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter Also in some cases you may need to have the first letter of file names of controllers and models and class name as upper case as in codeigniter 3 I am not sure about it in codeigniter 3 –  Jun 30 '15 at 08:01
  • possible duplicate of [How to remove index.php in Wamp?](http://stackoverflow.com/questions/18208746/how-to-remove-index-php-in-wamp) – Saty Jun 30 '15 at 08:02
  • How i can check rewrite_module is enabled or not? – Shalu Jun 30 '15 at 08:06
  • check this [link1](http://stackoverflow.com/questions/7337724/how-to-check-whether-mod-rewrite-is-enable-on-server) and [link2](http://stackoverflow.com/questions/9021425/how-to-check-if-mod-rewrite-is-enabled-in-php) – Saty Jun 30 '15 at 08:12
  • i have checked phpinfo() but no apache configuration showing. – Shalu Jun 30 '15 at 08:22
  • @Shalu any live url to check this out?? – Abdulla Nilam Jun 30 '15 at 08:29

2 Answers2

8

I have solved the problem. I have made web.config in root directory of codeigniter. My Code is following.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite> 
    </system.webServer>
</configuration>

It is working for me. I hope this will help others too.

Shalu
  • 291
  • 1
  • 2
  • 11
0

place your .htaccess file within your codeiginter project directory then write this code in .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ project_dir_name/index.php/$1 [L]

Replace "project_dir_name" with you actual directory name in 3rd line.

If still you have problem then check your controller, method name and permission of folders and files.

Aniket Singh
  • 2,464
  • 1
  • 21
  • 32