Yii 2.0 hiding /basic/web from the URL along with the index.php

前端 未结 3 732
轮回少年
轮回少年 2021-01-06 17:09

Plenty of information around the net on how to hide the index.php from your Yii 2.0 application URL, however, what I\'m trying to do here is to also remove the \'/basic/web/

3条回答
  •  囚心锁ツ
    2021-01-06 17:53

    RewriteEngine on
    # Change yourdomain.com to be your primary domain.
    
    RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$
    
    RewriteCond %{REQUEST_URI} !^/basic/web/
    
    # Don't change this line.
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^(.*)$ /basic/web/$1
    
    RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$ 
    RewriteRule ^(/)?$ basic/web/index.php [L]
    

    Change .htaccess permissions to 440 when you're done. Nothing to fear using this method, contrary to what is stated by Mihai P.

提交回复
热议问题