ShopWind电商系统基于优秀的开源框架 Yii2.0 流行开发,采用 MVC 开发模式,层次和视图层完美性,差异性高,安全高,适合开发大型WEB2.0的PHP框架。安装ShopWind电商系统需配置伪静态规则,各种Web服务器的伪静态配置方法如下。
1、Nginx伪静态规则,注意顺序
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /admin {
try_files $uri $uri/ /admin/index.php$is_args$args;
}
location /mobile {
try_files $uri $uri/ /mobile/index.php$is_args$args;
}
location /api {
try_files $uri $uri/ /api/index.php$is_args$args;
}
2、Apache伪静态规则
在项目根目录下 .htaccess 文件已经包含有,默认不需要设置。
<IfModule mod_rewrite.c>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
// if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
// 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
RewriteRule \.svn\/ /404.html
RewriteRule \.git\/ /404.html
</IfModule>
3、IIS伪静态规则
<?xml version="1.0" ?>
<rules>
<rule name="rewrite_admin_rewrite" stopProcessing="true">
<match url="admin/?(.*)"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="admin/index.php" appendQueryString="true"/>
</rule>
<rule name="rewrite_api_rewrite" stopProcessing="true">
<match url="api/?(.*)"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="api/index.php" appendQueryString="true"/>
</rule>
<rule name="rewrite_mobile_rewrite" stopProcessing="true">
<match url="mobile/?(.*)"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="mobile/index.php" appendQueryString="true"/>
</rule>
<rule name="rewrite_rewrite" stopProcessing="true">
<match url="." ignoreCase="false"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true"/>
</rule>
</rules>
4、不启用伪静态配置
打开common\config\main.php文件 设置'enablePrettyUrl' => false