0

I am using Codeigniter framework in PHP. My website is on apache server. Path: /var/www/example.com/public_html

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

But still I am getting this error on accessing this page: www.example.com/test/wallet:

The requested URL /test/wallet was not found on this server.

SCREEN SHOT

enter image description here

When I use www.example.com/index.php/test/wallet, then it's working...

RNK
  • 5,582
  • 11
  • 65
  • 133
  • Check your controller file and methods. Can you share us controller codes? Do you use CodeIgniter v3? – Bora Jun 12 '15 at 21:30
  • Have you changed `$config['index_page'] = 'index.php';` to `$config['index_page'] = '';` in `config.php`? It looks like your .htaccess is attempting to remove the index.php from the URL. – shermanzach Jun 12 '15 at 21:30
  • 1
    `example.com/index.php/test/wallet` URL is working? – Bora Jun 12 '15 at 21:33
  • Begin from: does anything work ? :) – splash58 Jun 12 '15 at 21:34
  • @Bora: Yes. That URL is working – RNK Jun 12 '15 at 21:34
  • It's `$config['index_page'] = '';` in my config file – RNK Jun 12 '15 at 21:35
  • Can you try following `.htaccess` please? ` 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] ` – Bora Jun 12 '15 at 21:37
  • @Bora: No. It's same error. – RNK Jun 12 '15 at 21:39
  • By the way, it is strange condition `RewriteCond $1 !^(index\.php|public|\.txt)` - index.php or public or .txt - at the start – splash58 Jun 12 '15 at 21:50
  • change your last line from RewriteRule ^(.*)$ index.php?$1 to `RewriteRule ^(.*)$ /index.php/$1 [L]` – Nassim Jun 13 '15 at 00:14
  • did you find a solution to your problem ? – Nassim Jun 14 '15 at 07:44
  • @Nassim: No. I am still getting the same error. – RNK Jun 15 '15 at 20:32
  • Does the server allow rewriting? Check phpinfo() output if that module is loaded. Note that this is not a test for all setups, but if it does not show there maybe good to look in that direction. Some more info: http://stackoverflow.com/questions/7337724/how-to-check-whether-mod-rewrite-is-enable-on-server – g_uint Jun 15 '15 at 21:24

3 Answers3

1

this is my .htaccess that works on both wamp and live linux server running Centos + Apache and Ubuntu +apache

RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /path-to-code-igniter-directory/index.php/$1 [L]

# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]

I also made a video on how to do this here

https://www.youtube.com/watch?v=v-4VkR54vLU

(skip to 28:50 to see the .htaccess .I also put it in the description under the video)

hope that helps

Nassim
  • 2,879
  • 2
  • 37
  • 39
1

problem is with your URL rewrite.

place this outside application folder

File name = .htacess

in side

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
0

I think all of your .htaccess setting are correct. I used @Nassim's solution.

Originally, Problem was with the configurations in apache2.conf file. I just set AllowOverride All in /var/www and activated rewrite on server by this command:

sudo a2enmod rewrite

Then I restarted my server: sudo service apache2 restart

Thanks to every1 for support.

RNK
  • 5,582
  • 11
  • 65
  • 133