第一种方法 Nginx环境
先去typecho设置里开启重写功能,开启失败选择强制开启。
在宝塔里面网站点击设置选择伪静态,选择typecho会自动生成代码。
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
如果typecho是子目录选择typecho2
location /typecho/ {
if (!-e $request_filename) {
rewrite ^(.*)$ /typecho/index.php$1 last;
}
}
记得把typecho换成你的目录名
方法二 IIS服务器重写web.config
重写关键代码:
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="XXX/index.php/{R:1}" />
</rule>
</rules>
</rewrite>
如果Typecho是子目录请修改第9行代码url="XXX/index.php/{R:1}" />
XXX是你的目录名
web.config完整代码:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="XXX/index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
如果Typecho是子目录请修改第12行代码url="XXX/index.php/{R:1}" />
XXX是你的目录名
一般空间web.config文件是有配置的请勿删除!
把关键代码放在<system.webServer></system.webServer>之间
比如下面的有php切换,只需要放在<system.webServer>与
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="PHP-7.2-7i24.com" />
<remove name="PHP-7.1-7i24.com" />
<remove name="PHP-7.0-7i24.com" />
<remove name="PHP-5.6-7i24.com" />
<remove name="PHP-5.5-7i24.com" />
<remove name="PHP-5.4-7i24.com" />
<remove name="PHP-5.3-7i24.com" />
<remove name="PHP-5.2-7i24.com" />
<add name="PHP-5.6-7i24.com" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="c:\php\5.6\php-cgi.exe" resourceType="Either" />
</handlers>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="XXX/index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
如果Typecho是子目录请修改第23行代码url="XXX/index.php/{R:1}" />
XXX是你的目录名
部分内容转至:点击访问
本文共 196 个字数,平均阅读时长 ≈ 1分钟
评论 (0)