侧边栏壁纸
博主头像
Jammmの日常博主等级

行动起来,活在当下

  • 累计撰写 71 篇文章
  • 累计创建 47 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

关于Typecho伪静态设置【包含Nginx、IIS】

Administrator
2020-02-25 / 0 评论 / 0 点赞 / 7 阅读 / 5991 字

第一种方法 Nginx环境

先去typecho设置里开启重写功能,开启失败选择强制开启

在宝塔里面网站点击设置选择伪静态,选择typecho会自动生成代码。 baota1

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}

如果typecho是子目录选择typecho2 baota2

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是你的目录名

部分内容转至:点击访问

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区