Htaccess for Yii2 Advanced Template

This entry was posted in Yii2 on 2018-08-04 by Eddy
3573 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:

http://yourdomain.com

And backend:

http://yourdomain.com/backend

Comments

Affichage de 1-1 sur 1 élément.

Swapnil c*i*k*s*a*n*l@gmail.com

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