0

Hi successfully removed the index.php in my url, however the [controller folder]/[function]/[argument] isn't working anymore

this is my htacess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

I've also changed this

$config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';

this is my config['base_url']

$base  = "http://".$_SERVER['HTTP_HOST'];
$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $base;

and I have changed my http.conf in apache AllowOverride All

I've also restarted my xampp already, Cna anyone help me why the [controller folder]/[function]/[argument] is not working?

geek_10101010
  • 90
  • 1
  • 4
  • 19
  • You can follow this [link](https://stackoverflow.com/questions/46608887/codeigniter-3-1-6-how-to-remove-index-php-from-url/46615615#46615615) to the same QA. – Harish Oct 07 '17 at 22:50

3 Answers3

1

Update your .htaccess script as:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /codeigniter
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Vickel
  • 7,879
  • 6
  • 35
  • 56
Harish
  • 462
  • 6
  • 13
  • it's not working :( , before, it says 404 page not found, now it says object not found – geek_10101010 Oct 07 '17 at 23:06
  • 1
    404 was the .htaccess error but object not found it probably an error somewhere in controller or model – Harish Oct 07 '17 at 23:09
  • i tried this RewriteEngine On RewriteBase /codeigniter RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] – geek_10101010 Oct 07 '17 at 23:12
  • and it works, however i don't want to kept on changing the RewriteBase when i wanted to change the file name of the system, can this be done? – geek_10101010 Oct 07 '17 at 23:13
  • 1
    this code of htaccess is used to remove the index.php from the URL, So in this case, we need to use `RewriteBase /`. – Harish Oct 07 '17 at 23:19
  • @domin0101 I also edited my answer for you, If its the exact answer that worked for you then please you can make it as accepted. – Harish Oct 07 '17 at 23:20
  • I used `RewriteBase /` but the site went to the localhost/dashboard – geek_10101010 Oct 07 '17 at 23:21
  • No, I mean you also need to specify your directory name with it like you did `RewriteBase /codeigniter` – Harish Oct 07 '17 at 23:23
1
RewriteEngine On
RewriteBase /codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteBase /[file name].

geek_10101010
  • 90
  • 1
  • 4
  • 19
1

use this to avoid changing your RewriteBase

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>