Php yii2中的URL管理器问题
这是我的后端url:Php yii2中的URL管理器问题,php,.htaccess,yii2,Php,.htaccess,Yii2,这是我的后端url:http://localhost/game_website_new/phase1/admin/工作正常,但是 现在我在我的应用程序目录中有一个论坛文件夹,它可以在前端像这样访问:http://localhost/game_website_new/phase1/forum正在工作 但是我想在后台使用论坛,就像这样:http://localhost/game_website_new/phase1/admin/forum但这不起作用 下面是我的网站.htaccess文件 # pre
http://localhost/game_website_new/phase1/admin/
工作正常,但是
现在我在我的应用程序目录中有一个论坛
文件夹,它可以在前端像这样访问:http://localhost/game_website_new/phase1/forum
正在工作
但是我想在后台使用论坛,就像这样:http://localhost/game_website_new/phase1/admin/forum
但这不起作用
下面是我的网站.htaccess
文件
# prevent directory listings
Options -Indexes
IndexIgnore */*
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^admin(.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web/$1
你可以去
config
(如果您在应用程序的common/config
)文件夹中使用高级应用程序,然后打开web.php
或main.php
,您将看到类似的内容
$config = [
'urlManager' => [
//some configs here
],
搜索“urlManager”以查找配置文件
看看上面的医生
我想这应该行得通
$config = [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
//you can use regexp in parameters
'your/new/url/<parameterId:\d+>' => 'old/url', // old url will match something like moduleIfYouHaveOne/YourController/YourAction
'phase1/admin/forum' => 'phase1/forum',
],
$config=[
“urlManager”=>[
“enablePrettyUrl”=>true,
'showScriptName'=>false,
'enableStrictParsing'=>false,
“规则”=>[
//可以在参数中使用regexp
'your/new/url/'=>'old/url',//旧url将与moduleIfYouHaveOne/YourController/YourAction匹配
“阶段1/管理/论坛”=>“阶段1/论坛”,
],