Htaccess for Yii2 Advanced Template

This entry was posted in Yii2 on 2018-08-04 by Eddy
4361 Yii2 .htaccess

Edit or create .htaccess in your root folder

RewriteEngine On

# Redirect to WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Hide robot.txt
RewriteRule ^robots.txt - [L]

# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend)/web/ - [L]

# Rule for Images folder
RewriteCond %{REQUEST_URI} /(images)
RewriteRule ^images/(.*)$ images/$1 [L]

# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^backend(/(.*))?$ backend/web/$2 [S=1]

# handle the case of frontend
RewriteRule .* frontend/web/$0

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/web)/.*$ $1/index.php

Edit or create htaccess in frontend/web

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L]

You can now access to frontend:

And backend:


Showing 1-1 of 1 item.

Swapnil c*i*k*s*a*n*

Thank You Its very great and saved lots of time
thank you

Write comments

Math, for example, 45-12 = 33

Subscribe Now

You will receive a notification to each new article.

Tag Cloud

  • Composer
  • Yii2
  • OpenGraph
  • Helper
  • Wordpress
  • PhpMyAdmin
  • .htaccess
  • Config
  • Production
  • Git
  • Api
  • Mailchimp
  • Github
  • Vue.js