Answer the question
In order to leave comments, you need to log in
How to setup .htaccess for Yii2 in XAMPP?
Hey! Hosting is ok. On locale in XAMPP put in /htdocs/site.ru. But all urls and assest bypass the domain and refer to localhost/assets, locahost/contacts and so on.
# Mod_Autoindex
<IfModule mod_autoindex.c>
# запрет просмотра директорий
Options -Indexes
</IfModule>
# Mod_Rewrite
<IfModule mod_rewrite.c>
Options +FollowSymlinks
# включаем mod_rewrite
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://site.ru/$1 [R,L]
</IfModule>
<IfModule mod_rewrite.c>
# Backend redirect
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(.*)$ backend/web/$1 [L]
# Frontend redirect
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*)$ frontend/web/$1
</IfModule>
Answer the question
In order to leave comments, you need to log in
Good afternoon.
In addition to .htaccess in the root of the project, we also need .htaccess in frontend/web and backend/web with the following content
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question