1

I'm having problems setting up my .htaccess file. In my web folder (in the root of my project) I have index.php . Now I have to go to mydomain.com/web/ to see my index.php .

I've added a .htacces file in my /web folder but it isn't working. This is the content of my .htaccess file:

<IfModule mod_rewrite.c>
   RewriteEngine On

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

What am I doing wrong?

nielsv
  • 6,540
  • 35
  • 111
  • 215

2 Answers2

1

You can have 2 .htaccess for this:

root .htaccess (a level above web):

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!web/).*)$ web/$1 [NC,L]

/web/.htaccess:

RewriteEngine On
RewriteBase /web/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

Have you tried RewriteBase ?

RewriteBase /web/

This post can be also helpful

Community
  • 1
  • 1
Paul T. Rawkeen
  • 3,994
  • 3
  • 35
  • 51
  • Tried to add it but same result – nielsv Apr 24 '15 at 13:10
  • @nielsv, what if you try smth like this `RewriteRule ^([^?]*)$ index.php?path=$1 [NC,L,QSA]`. `.htaccess` should be in folder where `index.php` locates. Or `RewriteRule ^([^?]*)$ /web/index.php?path=$1 [NC,L,QSA]` if `.htaccess` location is *root*. – Paul T. Rawkeen Apr 24 '15 at 13:35