我有一个带有前端和后端的 yii 高级应用程序。
我试图实现的是我可以使用客户的名字访问前端。
示例(本地):http://localhost/myproject/frontend/web/customer1
应该成为http://localhost/myproject/frontend/web/customer1/site/login
第一次访问
登录后,客户的姓名应保留在 URL 中。目前,登录后URL更改为http://localhost/myproject/frontend/web/
信息:
customer
是一个 GET 参数。它应该始终是之后的第一个参数,http://localhost/myproject/frontend/web/
但我不想在每个重定向或自定义链接中指定参数。我希望有一种方法可以保留此参数并将其传递给以下每个站点更改。
到目前为止我已经尝试过:
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
'<controller>/<action>' => '<controller>/<action>',
'<customer:\w+>' => '/site/login',
]
],
但这不起作用。我只能访问登录页面,之后客户名称不再显示在 URL 中。
我的 .htaccess 文件如下所示:
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
我非常感谢有关此主题的任何提示。