我有我的yii2應用程序高級項目的單域配置。在配置工作正常之前,但現在我無法管理任何圖像文件的鏈接。當我試圖通過http://{domain}/icons/logo.svg
鏈接下載文件,我有404錯誤:404找不到文件鏈接在Yii2應用程序 - 先進的單域配置
Not Found
The requested URL /icons/logo.svg was not found on this server.
但http://{domain}/frontend/web/icons/logo.svg
作品。 文件存在於顯示文件夾中。如何糾正項目中的apache配置文件以使用短鏈接。
這裏我的配置:
阿帕奇:
<VirtualHost *:80> ServerName test.dev ServerAdmin [email protected] DocumentRoot /home/user/Projects/test-app/ <Directory /home/user/Projects/test-app/> Require all granted AllowOverride All </Directory> </VirtualHost>
基地
.htacces
:Options -Indexes IndexIgnore */* Options +SymLinksIfOwnerMatch <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ RewriteRule ^(.*)$ http://%1/$1 [L,R=301] RewriteRule ^admin(.{2,})?(/)?$ /backend/web/$1 [L,PT] RewriteRule ^([^/].*)?$ /frontend/web/$1 </IfModule>
前端
.htacces
:Options -Indexes <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php </IfModule> DirectoryIndex index.php
- 在配置文件中
frontend\config\main.php
也使:
- 在配置文件中
'components' => [
'request' => [
'csrfParam' => '_csrf-frontend',
'baseUrl' => '',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'sitemap' => 'sitemap/index',
],
],
Sardor Dushamov,你的變種不工作了。 除此之外,在問題配置中描述在我的電腦上的其他yii2項目中工作正常。也許,有些錯誤更一般? – Oleg