yii2.0配置以pathinfo的形式访问,yii2.0pathinfo
yii2.0默认的访问形式为:dxr.com/index.php?r=index/list,一般我们都会配置成pathinfo的形式来访问:dxr.com/index/list,这样更符合用户习惯。
具体的配置方法为:
一.配置yii2.0。
打开config目录下的web.php,在$config = [ 'components'=>[ 加到这里 ] ]中加入:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
此时,yii2.0已经支持以pathinfo的形式访问了,如果此时访问不了,继续往下看。
二.配置web服务器。
1.如果是apache,在入口文件(index.php)所在的目录下新建一个文本文件,接着另存为.htaccess,用记事本打开此文件加入:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
保存即可。
2.如果是nginx,在nginx配置文件中加入:
server {
listen 80;
server_name www.daixiaorui.com;
location / {
root E:/wwwroot/yii2.0;
index index.html index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~ \.php$ {
root E:/wwwroot/yii2.0;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
三:重启web服务器。
至此,配置完毕。
文章出自:http://www.daixiaorui.com/read/218.html 本站所有文章,除注明出处外皆为原创,转载请注明本文地址,版权所有。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
