Remove index.php from site_url function in codeigniter

I removed index.php from url by installing the .htaccess file. Now I want to remove index.php from the return value of site_url (), because I do not want search engine caches to contain my index.php URLs. For example, when I use site_url () as part of my project, search engines cache the URL, for example http: //url/index.php/controller . I remove index.php from the site_url function in system / helper, but I think the redirect functions and form_open are not working properly.

+6
source share
2 answers

write in the .htaccess file

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] 

And set the index_page configuration in config.php

 $config['index_page'] = ''; 
+12
source

You can use the base_url() function:

 echo base_url(); // http://example.com/website echo site_url(); // http://example.com/website/index.php 
+2
source

Source: https://habr.com/ru/post/984368/


All Articles