0

My project (codeigniter) runs on Windows 7

Now my URL looks like:

http://dev.something.com/index.php/reports

and I want:

http://dev.something.com/reports

I try to hide index.php from my URL in order to get access to controller.

From this link I took .htaccess

So my .htaccess looks like:

Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|app|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

But this change didn't help me.

Important:

I cleared all data from .htaccess but nothing happened. Sounds like Codeigniter don't see .htaccess

.htaccess stays under my root project a.e.:

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\someprog_dev\.htaccess

[EDIT 1]

The same project works fine on Linux so its not codeigniter configuration problem

[EDIT 2]

I change .htaccess to be sure that codeigniter uses .htaccess:

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

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule> 

Nothing happens. Works with index.php but not without one.

[EDIT 3]

My httpd.conf looks like:

....

LoadModule rewrite_module modules/mod_rewrite.so

...

LoadModule php5_module "c:/php/php5apache2_2.dll"
<IfModule php5_module>
    AddType application/x-httpd-php .php
    PHPIniDir c:/php/
    DirectoryIndex index.php index.html
</IfModule>

Did I miss something? any suggestions

snaggs
  • 5,543
  • 17
  • 64
  • 127

4 Answers4

0

This never worked for me as well with codeigniter.. but the following did:

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

Replace the paths if necessary

Good reference: http://softkube.com/blog/url-rewriting-for-codeigniter/

Yami
  • 1,405
  • 1
  • 11
  • 16
0

Try these

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

My .htaccess is as simple as

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

and works perfectly. But you need to have everything in CI's config files properly set, and the rule must match your $config['base_url'].

So if you have

$config['base_url'] = 'http://localhost/myapp/';

You have to put

RewriteRule ^(.*)$ /myapp/index.php?/$1 [L]
Christian Dechery
  • 876
  • 10
  • 31
  • The problem that code works on Linux. I can't change project config. – snaggs Jan 13 '14 at 11:00
  • So it looks like an environment related issue. On Linux does it fall under the exact same relative path to the root? Are there any different redirects on apache? (you already mentioned mod_rewrite is ok on Win7) – Christian Dechery Jan 13 '14 at 11:32
0

Try this htaccess.It's working well.

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

Change the index.php to whatever your main controller.

CodeCanyon
  • 929
  • 2
  • 11
  • 36