Web前端 - localhost(LAMP中的目录apache2 / htdocs),web后端 - localhost:8080 / backend(apache2 / htdocs / backend)。 Yii使用htdocs在同一目录中高级应用程序 - mafia-yii(apache2 / mafia-yii)。在backend / config中输入main.php:
'components' => [
....
'urlManager' => [
// here is your normal backend url manager config
'class' => 'yii\web\UrlManager',
'baseUrl' => 'http://localhost/backend',
],
'urlManagerFrontend' => [
'class' => 'yii\web\UrlManager',
'hostInfo' => 'http://localhost',
'baseUrl' => 'http://localhost',
],
],
file~ / lampstack-7.0.4-0 / apache2 / mafia-yii / backend / views / layouts / main.php:
....
$menuItems[] = ['label' => 'Backend', 'url' => ['/site/index']];
$menuItems[] = ['label' => 'Fronend', 'url' => [Yii::$app->urlManagerFrontend->createUrl('/site/index')]];
....
结果: http://localhost:8080/backend/index.php?r=backend%2Findex.php%3Fr%3Dsite%252Findex
未找到(#404)
答案 0 :(得分:1)
您是否尝试过:
//Edit image row
private void EditImageBtn_Click(object sender, EventArgs e)
{
try
{
EditImageForm Image = new EditImageForm();
Image.imageidTxt.Text = this.imageGridView.CurrentRow.Cells[0].Value.ToString();
//Image.picImg.Text = this.imageGridView.CurrentRow.Cells[1].Value.ToString();
Image.nameTxt.Text = this.imageGridView.CurrentRow.Cells[2].Value.ToString();
Image.recipeCombo.Text = this.imageGridView.CurrentRow.Cells[3].Value.ToString();
Image.ShowDialog();
loadImageTable();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
答案 1 :(得分:0)
尝试使用以下代码:
use yii\helpers\Url;
$menuItems[] = ['label' => 'Fronend', 'url' => Url::to(Yii::getAlias('@web') . '/site/index', true)];
答案 2 :(得分:0)
我解决了这个问题。的因为:强>
$var[] = Yii::getAlias('@webroot');
$var[] = Yii::getAlias('@web');
\yii\helpers\VarDumper::dump($var);
<强>返回:强> [0 => &#39; /home/kira/lampstack-7.0.4-0/apache2/htdocs/backend' 1 =&gt; &#39; /后端&#39; ]
解决方案是: $ menuItems [] = [&#39;标签&#39; =&GT; &#39; Frontend&#39;,&#39; url&#39; =&GT; &#39; @web /../ 39];