Yii2.0 basic 如何配置apache的.htaccess

RT. Yii2.0 basic 如何配置apache的.htaccess

  1. 根目录下

     RewriteEngine on
     RewriteRule ^$ web/
     # if a directory or a file exists, use it directly
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
    
     # otherwise forward it to index.php
     RewriteRule ^(.*)$ web/$1
    
  2. web目录下

     RewriteEngine on
     # If a directory or a file exists, use it directly
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     # Otherwise forward it to index.php
     RewriteRule . index.php