0

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.

Matic-C
  • 783
  • 2
  • 11
  • 16

1 Answers1

0

Should be just a matter of rewriting:

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

To:

ReWriteCond %{REQUEST_URI} !en/
ReWriteRule ^(.*)$ en/$1 [L]
eomer
  • 397
  • 1
  • 3
  • 14
  • I now get 404 Unable to find theme layout: index – Matic-C Nov 26 '14 at 09:56
  • Is your layout still under the public folder or under en? – eomer Nov 26 '14 at 09:58
  • themes and assets are still under public folder – Matic-C Nov 26 '14 at 10:05
  • Yeah that is why it cannot find them. I imagine your code (and codeigniter) assumes they are under the same directory. This will forward the request as if it hit the en directory to start with. – eomer Nov 26 '14 at 10:07
  • If I move them to the `root/en` they would be in the same folder as application directory, is this safe? I really just want to make my `root/en` the new root folder for my application – Matic-C Nov 26 '14 at 10:08
  • Sorry I work with Cakephp much more and it is a little different. Have you looked at this https://ellislab.com/codeigniter/user-guide/installation/index.html ? I think this may be closer to what you are looking for. – eomer Nov 26 '14 at 10:11
  • accepted your answer as it helped me although not exactly as I wanted but my next question should really be another topic – Matic-C Nov 26 '14 at 10:18