Changing the root folder via .htaccess

Hello , I’m using Apache with yii2 and i have 2 route /en , /ar i want app by default open to /ar

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)${REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)${REQUEST_URI} [R=301,L]

RewriteEngine on
#RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)${REQUEST_URI} [R=301,L]

# Preventing Redirect loop
RewriteRule ^(frontend|backend)/web/ - [L]
RewriteRule ^(common)/web/ - [L]

RewriteCond %{REQUEST_URI} !^/api
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_URI} !^/app
RewriteCond %{REQUEST_URI} !^/backend
RewriteCond %{REQUEST_URI} !^/uploads

RewriteRule ^(.*)$ /frontend/web/index.php/$1 [L]


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Doing this via the .htaccess might be a bit tricky, instead I believe that this extension would work for you:

It is quite flexible and configurable, you could specify the following scenario:

/               -> Redirect to /ar
/some/page      -> Redirect to /ar/some/page

Regards, Bobby