最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

yii框架怎么设置伪静态

来源:动视网 责编:小采 时间:2020-11-03 18:18:11
文档

yii框架怎么设置伪静态

yii框架怎么设置伪静态:Apache服务器的配置修改httpd.conf配置文件1、将LoadModule rewrite_module modules/mod_rewrite.so前面的注释#号去掉。2、添加如下内容:<Directory "path/to/basic/web"> # use mod_rewrite
推荐度:
导读yii框架怎么设置伪静态:Apache服务器的配置修改httpd.conf配置文件1、将LoadModule rewrite_module modules/mod_rewrite.so前面的注释#号去掉。2、添加如下内容:<Directory "path/to/basic/web"> # use mod_rewrite


Apache服务器的配置

修改httpd.conf配置文件

1、将LoadModule rewrite_module modules/mod_rewrite.so前面的注释#号去掉。

2、添加如下内容:

<Directory "path/to/basic/web">
 # use mod_rewrite for pretty URL support
 RewriteEngine on
 # If a directory or a file exists, use the request directly
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 # Otherwise forward the request to index.php
 RewriteRule . index.php

 # ...other settings...
</Directory>

注意其中的path/to/basic/web修改成你的根目录,最后不要忘记重启apache服务器。

(推荐教程:yii框架)

Nginx服务器的配置

修改nginx.conf配置文件,在域名对应的server{}内添加如下内容:

location / {
 # Redirect everything that isn't a real file to index.php
 try_files $uri $uri/ /index.php$is_args$args;
}

最后不要忘记重载配置文件。

yii2代码的配置

修改config/web.php,在components数组中添加如下内容(去掉前后的注释)

'components' => [
 ...
 'urlManager' => [
 'enablePrettyUrl' => true,
 'showScriptName' => false,
 'rules' => [
 ],
 ],
 ...
],

这时再刷新网页,就能看到连接的形式发生了改变。此时默认会将/index.php?r=controller/action这样的形式修改为/controller/action(如果含有参数,则将/index.php?r=controller/action&...改为/controller/action?...)。

更多编程相关内容,请访问Gxlcms编程教程栏目!

文档

yii框架怎么设置伪静态

yii框架怎么设置伪静态:Apache服务器的配置修改httpd.conf配置文件1、将LoadModule rewrite_module modules/mod_rewrite.so前面的注释#号去掉。2、添加如下内容:<Directory "path/to/basic/web"> # use mod_rewrite
推荐度:
标签: 设置 配置 框架
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top