如何配置伪静态
- 梦雨
- 0
- 198
- 2020-12-22
- 2020-12-22
配置伪静态可以使网站的路径更佳的短 如果你的服务器或者主机不支持伪静态 我们可以在根目录index.php添加如下代码保证网站正常运行
define('index', '/index.php');
你的主机,服务器支持配置伪静态那自然更好 去根目录index.php修改代码 如图
define('index', '/');
配置伪静态
如果你是宝特用户可以在网站站点修改一键配置如图 保存即可
如果是其他可以配置下面的伪静态规则
Nginx伪静态 一般命名Nginx.conf
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
Apache伪静态 一般命名.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
IIS伪静态 一般命名web.Config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^(.*)$" ></match>
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)$" ></add>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" ></add>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" ></add>
</conditions>
<action type="Rewrite" url="index.php/{R:1}" ></action>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
评论
0 条评论