yii2 伪静态设置backend/frontend/api
1、 apache
PHP Code复制内容到剪贴板
- web/.htaccess
- web/admin/.htaccess
- web/api/.htaccess
你只需要保证apache的AllowOverride为All
2、nginx
PHP Code复制内容到剪贴板
- server {
- server_name www.yourserver.com;
- listen 80;
- index index.html index.htm index.php;
- root your-yii2cmf-path/web;
- location / {
- try_files $uri $uri/ /index.php?$query_string;
- }
- location /admin {
- try_files $uri $uri/ /admin/index.php?$query_string;
- }
- location /api {
- try_files $uri $uri/ /api/index.php?$query_string;
- }
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000;
- include fastcgi.conf;
- }
- }
满足以上条件后,可以到模块管理urlrule模块配置开启url美化