php.htaccesscodeignitermod-rewritebonfire

Codeigniter front controller location and proper .htaccess


How should my .htaccess code look like if I move my front controller? More specific, I had front controller in the following directory: root/public/index.php and my .htaccess looked like so:

RewriteEngine on
RewriteBase /

ReWriteCond %{REQUEST_URI} !public/
ReWriteRule ^(.*)$ public/$1 [L]

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

Now when I move front controller to: root/en/index.php obviously my .htaccess becomes obosolete. Also I think I must change the path in my front controller? But lets fix the .htaccess first to work with the new structure.


Solution

  • Should be just a matter of rewriting:

    ReWriteCond %{REQUEST_URI} !public/
    ReWriteRule ^(.*)$ public/$1 [L]
    

    To:

    ReWriteCond %{REQUEST_URI} !en/
    ReWriteRule ^(.*)$ en/$1 [L]