网站首页 > 帮助中心 > 虚拟主机问题 > 正文
thinkphp程序怎么在虚拟主机或网站空间中部署?并设置伪静态规则?thinkphp程序在虚拟主机或全能空间中部署,并设置伪静态方法如下:
以千百互联的免备案空间为例,需要在根目录下设置2个规则文件: .htaccess 和 web.config文件:
.htaccess文件代码如下:
RewriteEngine On
# 2. 静态文件直接访问(重要!)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# 3. 核心重写规则(使用兼容模式)
# 注意:这里使用 `?s=/$1` 参数模式
RewriteCond %{REQUEST_URI} ^/ [OR]
RewriteCond %{HTTP_HOST} ^www\.idcqb\.com$ [NC]
RewriteRule ^(.*)$ /index.php?s=/$1 [QSA,L]
web.config 文件代码如下: xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Dynamic for sxhl" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.idcqb\.com$" />
<add input="{URL}" pattern="^/public/" negate="true" />
<add input="{URL}" pattern="\.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot|mp3|mp4|pdf)$" negate="true" />
conditions>
<action type="Rewrite" url="/index.php?s=/{R:1}" />
rule>
<rule name="Static for sxhl" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.idcqb\.com$" />
conditions>
<action type="Rewrite" url="/{R:1}" />
rule>
rules>
rewrite>
system.webServer>
configuration>
上一篇:千百互联那些空间支持绑定子目录?
下一篇:没有资料
|



千百互联-专业IDC虚拟主机服务商