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?

2 Answers 2

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]
Sign up to request clarification or add additional context in comments.

3 Comments

That gave me the error : You don't have permission to access / on this server.
Can you check your actual DocumentRoot from Apache config?
How can I check this? Tried to find /etc/apache2/conf/httpd.conf but httpd.conf wasn't there.
0

Have you tried RewriteBase ?

RewriteBase /web/

This post can be also helpful

2 Comments

Tried to add it but same result
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.