宝塔安装HYBBS论坛程度,伪静态的设置方法
<h1 style="margin-bottom: 0.4em; line-height: 1.5;"><font color="#209361">宝塔安装HYBBS论坛程度,伪静态的设置方法</font><br></h1><h1 style="margin-bottom: 0.4em; line-height: 1.5;"><span style="color: rgb(32, 147, 97);"><br></span></h1><h1 style="margin-bottom: 0.4em; line-height: 1.5;"><span style="color: rgb(32, 147, 97);">宝塔安装</span> 伪静态 </h1><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;">站点设置->伪静态->请根据自己的环境输入以下代码保存</p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><br></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><b>Apache:</b></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><b><br></b></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1
</IfModule></pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;"><br></span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;"><b>nginx:</b></span></span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}</pre><hr style="margin-top: 0px; margin-bottom: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><h1 style="margin-bottom: 0.4em; line-height: 1.5;"><span style="color: rgb(32, 147, 97);">Apache</span> 伪静态 </h1><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">Apache的伪静态是最简单 易用的. </span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">直接在<strong>网站根目录</strong>下创建文件: <span style="color: rgb(227, 55, 55);"><span style="text-decoration-line: underline;">.htaccess</span> </span><span style="color: rgb(32, 147, 97);"> (注意: 不要在前面加什么 x.htaccess . 该文件不需要文件名 只需要后缀)</span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="text-decoration-line: underline;"><br></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">写入内容: </span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1
</IfModule></pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">如果完成以上操作 依然无法使用. 那可能是你的Apache为开启伪静态模块</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">在Apache 安装目录中找到 <span style="color: rgb(227, 55, 55);">conf</span><span style="color: rgb(32, 147, 97);">/</span><span style="color: rgb(227, 55, 55);">httpd.conf</span> 文件</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">在该文件中搜索 : mod_rewrite </span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">即可找到关键字</span></span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">#LoadModule rewrite_module modules/mod_rewrite.so</pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">如果你看到 前面有一个# 号 说明伪静态模块并未开启</span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">所以你需要将 #号去除, 保存文件 重启Apache进程即可! 不会重启Apache的 请重启主机吧!</span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><br></p><h1 style="margin-bottom: 0.4em; line-height: 1.5;"><span style="color: rgb(65, 140, 175);">Nginx</span></h1><hr style="margin-top: 0px; margin-bottom: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">Nginx的伪静态安装时<strong>比较麻烦</strong>的, 因为Nginx一般会在Linux下安装使用, 空间以及Windows用的较少.</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">你需要来到Nginx的Conf目录</span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">这里用LNMP的安装目录作为说明</span></span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;"><span style="line-height: 28.8px;">LNMP中的Nginx目录在 /usr/local/nginx中</span></span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"># cd /usr/local/nginx/conf/vhost</pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">在目录中找到你的网站目录vhost</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">(这里可能有人不理解 我也不知道怎么说的明白)</span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"># vi 你的目录名.conf</pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">打开文件后可见内容:</span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">server
{
listen 80;
#listen [::]:80;
server_name bbs.hyphp.cn bbs.hyyyp.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/bbs.hyphp.cn;
include other.conf;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
......
........
...
省略..</pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">在中间插入: </span></p><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}</pre><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">server
{
listen 80;
#listen [::]:80;
server_name bbs.hyphp.cn bbs.hyyyp.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/bbs.hyphp.cn;
include other.conf;
#error_page 404 /404.html;
include enable-php.conf;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}</pre><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">插入后就是上面的结构了 </span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">保存该Conf即可</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">重启Nginx 完成</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><br></p><hr style="margin-top: 0px; margin-bottom: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><h1 style="margin-bottom: 0.4em; line-height: 1.5;">IIS 7 以上</h1><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">IIS7版本以上安装了URL重写支持才会支持 <strong>Web.config</strong> 伪静态</span></p><p style="font-family: "PingFang SC", "Lantinghei SC", "Microsoft Yahei", "Hiragino Sans GB", "Microsoft Sans Serif", "WenQuanYi Micro Hei", sans;"><span style="font-size: 18px;">在根目录写入以下内容 保存为 <span style="color: rgb(51, 51, 51); font-size: large; line-height: 28.8px;"> </span><strong style="color: rgb(51, 51, 51); font-size: large; line-height: 28.8px;">Web.config</strong></span></p><pre class="brush: csharp" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><pre class="" style="padding: 0px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?s={R:1}" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
<security>
<requestFiltering allowDoubleEscaping="True" />
</security>
</system.webServer>
</configuration></pre></pre>
页:
[1]