简体   繁体   中英

.htaccess redirection issue in codeigniter

I am working in a site which has been developed in codeigniter , To remove index.php from url I wrote rewrite rule in htaccess, now , there is anotheher need to be arise, that is I need to replace http:// to www in url,for that I wrote the code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTP_HOST} ^vrinfosystem.com$
RewriteRule (.*) http://www.vrinfosystem.com/$1 [R=301,L] 
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

but I got issues, the stylesheet and js are no found. I changed the base url too but it didn't help. if I wrote following line above the HTTP_HOST RewriteRule ^(.*)$ index.php?/$1 [L] the it will work fine but the index.php will retain in url. Ho can I solve this issue?

are u sure u have changed your config?

if you don't go to application>config>config.php than scroll down till you find this

$config[‘index_page’] = 'index.php';

change it too

$config[‘index_page’] = '';

There are a group of different scripts for this. This is the only one that worked for me across several sites

RewriteEngine on

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM