Reputation: 33
I tried all the methods that are found including on this site. But it did not work redirect.
My config.php
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.**.ru$ [NC]
RewriteRule ^(.*)$ http://**.ru/$1 [R=301,L]
RewriteCond $1 !^(robots\.txt|index\.php|image\.php|favicon\.ico|upload|sotrudnik|generator|links|assets|agents|old|sitemap\.xml|4cc707e99fb15630dc\.html|sitemap_mobile\.xml|yandex_6bfb7e8daf6b3458\.html|holder\.js)
RewriteRule ^(.*)$ /index.php/$1 [L]
this .htaccess
Upvotes: 2
Views: 2642
Reputation:
I use windows and xampp.
With this htaccess in main directory
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Once created htaccess in main directory then go to config.php look for the index_page make sure is blank like below
$config['index_page'] = '';
More examples found here https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter
You also may need to configure your routes in application/config/routes.php
http://www.codeigniter.com/user_guide/general/routing.html
Upvotes: 0
Reputation: 7675
You can try with the following .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
And please change your config.php like bellow:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Do not forget to enable mod_rewrite
.
Upvotes: 1
Reputation: 2206
You can use mod-rewrite of Apache to rewrite paths that do not contains "index.php" into /index.php/*** paths, for example this way :
.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php/$1 [L]
I think you should restore original value of $config['index_page'] : this is not the solution and it can have drawbacks
Upvotes: 1