Reputation: 1
After many time, I really don't understand why my rewrite rule doesn't ok. I use CI framework and I need to go to controller /show/place/1 when I set /france in URI.
This is my code :
Options +FollowSymLinks
SetEnv PHP_VER 5
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|img\/|css\/|js\/|favicon.ico)
RewriteRule ^(.*)$ /index.php/$1 [PT,L]
RewriteRule ^france$ index.php/show/place/1 [PT,L]
Someone can help me please?
Upvotes: 0
Views: 62
Reputation: 1011
Have you also set the config.php $config['index_page'] to blank?
change $config['index_page'] = 'index.php';
to -> $config['index_page'] = '';
Upvotes: 0
Reputation: 298
take a look at URI Routing Class http://ellislab.com/codeigniter%20/user-guide/general/routing.html for your question here is a snippet Go to /application/config/routes.php and add this:
$route['france'] = 'show/place/1';
in .htaccess file just remove the index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt)
RewriteRule (.*) index.php?/$1 [L]
Upvotes: 0
Reputation: 785296
Try chancing order of your rules:
Options +FollowSymLinks
SetEnv PHP_VER 5
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|img\/|css\/|js\/|favicon.ico)
RewriteRule ^france$ index.php/show/place/1 [PT,L]
RewriteRule ^((?!index\.php/).*)$ /index.php/$1 [PT,L]
Upvotes: 0
Reputation: 1357
It is much more convinient to use Codeigniter URI Routing for this, see http://ellislab.com/codeigniter%20/user-guide/general/routing.html
Upvotes: 2